+ Reply to Thread
Results 1 to 1 of 1

Thread: I have a php related question?

  1. #1
    Join Date
    Aug 2007
    Location
    Gangstas Paradise
    Posts
    4,143

    I have a php related question?

    In a php data strucutre,
    PHP Code:
    global $database;
    $database = array(
     array(
    'something''something_else'),
     array(
    'anotherthing''yet_another'),
     array(
    'almost_there''last_thing'),
    ); 
    you would extract as follows,
    PHP Code:
    print $database[0][0];  // should print the first scalar from the first array 
    so if i went,
    PHP Code:
    global $i;
    $i=0;
    foreach (
    $database as $a)
    {
     if (!
    $a[$i]) {break;} else {print $a[$i].'<br>';
    }
    // in this $a becomes the array's inside the data structure ? 
    &
    PHP Code:
    global $i;
    $i=0;
    foreach (
    $database as $a)
    {
     if (!
    $database[$i][0]) {break;} else { print $database[$i][0].'<br>';}
     
    $i++;
    }
    // this is now refrencing to the data structure that contains the arrays? 
    So this should print the whole data structure?
    PHP Code:
    foreach ($database as $a)
    {
     foreach (
    $a as $b)
     {
      if (!
    $b) {break;} else { print $b.'<br>';}
      
    $i++;
     }

    What I am aiming to do is this.

    Pass a varing amount of arrays to a include. The amount of scalars in the arrays is set and wont be more or less(some might be empty).
    I can get them across with "global" easily enough. What is getting me is that foreach scalar in an array, I need to assign another value to another data structure.

    would this work?
    PHP Code:
    global $ii;
    $ii=0;
    foreach (
    $database as $a)
    {
     foreach (
    $a as $b)
     {
      if (!
    $b) {break;} else { print $b.'<br>';}
      
    array_push($data2[$i][$ii],$b);
      
    $ii++;
     }
     
    $i++;
    }
    // cant figure this one out, example doesn't work ? 
    Basically for every scalar in each array in the 1st data structure, there needs to be one set in the 2nd data structure.

    ? ? ?

    If anyone could try and explain how to do this I would greatly appreciate it.
    I am sure I can return a favor.

    Regards,
    Edit:
    Does it matter how I define the "$data2"?
    Last edited by DefecTalisman; 09-20-2007 at 05:51 AM. Reason: Automerged Doublepost

    http://dev.x10hosting.com (this has nothing to do with x10hosting)

    ->All us helpful people here at x10hosting would like to reach our next user groups, "Community Paragon". Please click the +rep icon on the left hand side of a post if that post was helpfull.



+ Reply to Thread

Similar Threads

  1. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  2. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  3. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM
  4. http access and php read/write permissions.... one question !!
    By careerbridge in forum Scripts & 3rd Party Apps
    Replies: 8
    Last Post: 06-18-2006, 07:35 AM

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