hey all,

can someone please help me with this array problem.. im building a 2 dimentional array in a while loop. i copypasted the code here:
$tags[tag][] = stripComments($buffer);
$tags[regel][] = $teller;

now i have an array and i need to get the data out one at the time.. i tried the following:
foreach($tags[tag] as $tag) {
echo $tag;
}

but that wont work.. i can solve this with a counter that runs from 0 to the values of the array but thats not the nicest way to code.

help is more as welcome! 🙂

GR>
tiec

    You want to walk through each element of your multidimensional array? To do that you'll prpbably want to do this:

    <?php
    $mdim_array["one"][] = "1";
    $mdim_array["one"][] = "2";
    $mdim_array["one"][] = "3";
    $mdim_array["two"][] = "4";
    $mdim_array["two"][] = "5";
    $mdim_array["two"][] = "6";

    foreach($mdim_array as $dim) {
    foreach($dim as $value) {
    echo $value;
    }
    }

      You should do it this way :

      foreach($tags['tag'] as $key=>$tag){
      print $tag;
      }

        thnxz Hermawan Haryanto..
        you just made my life much easier with this.. works great!! 🙂

        tiec

          Write a Reply...