Jump to content

Looping array's


Ninjakreborn

Recommended Posts

I have always wondered how to do this.

Array

Products

  [414]

  [525]

  [3]

  [test1]

  [test2]

  [test3]

  [223]

assume each one has a giant subarray of whatever

foreach ($products as &$k) {

$products['test1'] = 'yes';

$products['test3'] = 'no';

if (is_numeric($k) {

 

}

}

In this situation how can I tell what "k" is set to since I need to access for example

$products['223']['subkey']

Then how would I know which number I was currently at?

Link to comment
https://forums.phpfreaks.com/topic/93709-looping-arrays/
Share on other sites

AND

 

$array[1]["man"]["head"]="big";

$array[1]["man"]["ear"]="small";

$array[1]["man"]["muchtash"]="gay";

 

$array[2]["man"]["head"]="big";

$array[2]["man"]["ear"]="small";

$array[2]["man"]["muchtash"]="lazered";

 

for($i=0;$i<count($array);$i++){

    echo

    $array[$i]["man"]["head"]="big";

    $array[$i]["man"]["ear"]="small";

    $array[$i]["man"]["muchtash"]="lazered";

}

Link to comment
https://forums.phpfreaks.com/topic/93709-looping-arrays/#findComment-480155
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.