[thelist] Php array, best way to...

Burhan Khalid thelist at meidomus.com
Sat Jul 10 08:19:18 CDT 2004


jsWalter wrote:

> I have an array with 100+ elements
> 
> Each element is an array of 75 elements
> 
> What would be the best way to retrieve a subset of elements from each
> the sub-array?
> 
> Say I wanted element 2 thru 6, 11 and 42 from each element of the main
> array?

foreach($array as $element)
{
   for($x = 2, $x <= 6; $x++)
   {
     if($element[$x] == "")
     {
        echo "There is no element at index ".$x."<br />";
     } else {
        $tmp[] = $element[$x];
     }
   }
}

[ snip ]




More information about the thelist mailing list