Closed Thread
Results 1 to 4 of 4

Thread: [200] PHP create array

  1. #1
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    [200] PHP create array

    I want to be able to update an array

    PHP Code:
    /* Plan Options */            // 'Plan Name' => 'Plan ID'
    $planOptions = array( 'Unlimited (5/month)'     => '1',
                          
    'Unlimited (50/year)'     => '2',
                          
    '500 texts (1/month)'     => '3',
                          
    '1500 texts (2/month)'    => '4',
                          
    '4000 texts (3/month)'    => '5',
                          
    '7000 texts (4/month)'    => '6'     // do NOT end the last one with a comma(,)
                        
    ); 
    and it places the array in a database, and when the user updates the database to add in a new plan, I also want it to update the configuration files.

    I'm thinking like fopen(), look for the end of $planOptions, insert the comma for the previous ending, then add in the new one(s), and don't insert the comma for the finishing one


    I am offering 200 credits to whoever can solve this for me
    Last edited by diabolo; 12-14-2008 at 08:35 AM.

  2. #2
    tttony's Avatar
    tttony is offline x10 Sophmore tttony is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    ~ 10°10'27.10''' N 67°59'59'.59''' O elev. 457m
    Posts
    147

    Re: [200] PHP create array

    do you need save the array content in a file??

    why not get the data from database and save into array and then works with that array??

    something like this:

    PHP Code:

    <?php

    $sql 
    "SELECT * FROM plan_table ORDER BY plan_id";
    $rs mysql_query($sql);

    $planOptions = array();

    while(
    $row mysql_fetch_assoc($rs)) 
    {

    //          'Plan Name'   =>    'Plan ID'
    $planOptions[$row['plan_name']] = $row['plan_id'];

    }

    // the array will look like this

    /* Plan Options */            // 'Plan Name' => 'Plan ID'
    $planOptions = array( 'Unlimited (5/month)'     => '1',
                          
    'Unlimited (50/year)'     => '2',
                          
    '500 texts (1/month)'     => '3',
                          
    '1500 texts (2/month)'    => '4',
                          
    '4000 texts (3/month)'    => '5',
                          
    '7000 texts (4/month)'    => '6'     // do NOT end the last one with a comma(,)
                        
    );  

    ?>
    PHP & MySQL Web Developer
    Free Domain co.cc

  3. #3
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Re: [200] PHP create array

    or. store them in an SQL db.

    with a backend to update it

    and use

    PHP Code:
    $planOptions explode(/*get the plans from the db*/); 
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  4. #4
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: [200] PHP create array

    actually guys, I am going a whole different route, so I don't need this any more
    thank you though!

Closed Thread

Similar Threads

  1. Places to learn php
    By JaWasabi in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 01-13-2009, 02:03 AM
  2. Cambios IMPORTANTES en PHP.
    By Fedlerner in forum Noticias y Anuncios
    Replies: 1
    Last Post: 11-06-2007, 11:13 AM
  3. Create image in PHP
    By alfred in forum Tutorials
    Replies: 2
    Last Post: 10-21-2007, 10:06 PM
  4. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers