Panjabel Posted August 13, 2008 Share Posted August 13, 2008 Hello, $ok = array(); array_push($ok, "value1"); foreach($ok as $value) { array_push($ok, "value2"); print $value; } // it won't print "value2" i want the script to read all values from array, in case there will be added a new value, to read it at the end and so on until there is no more values to read, Thanks Link to comment https://forums.phpfreaks.com/topic/119465-solved-array-probllem/ Share on other sites More sharing options...
spasme Posted August 13, 2008 Share Posted August 13, 2008 Maybe this will help: <? $ok = array(); array_push($ok, "value1"); foreach($ok as $value) { array_push($ok, "value2"); } print_r($ok); // this prints the whole array echo "<br>"; echo $ok[1]; // arrays start from [0] so the 2nd value si called using [1] and so on echo "<br>"; ?> Link to comment https://forums.phpfreaks.com/topic/119465-solved-array-probllem/#findComment-615407 Share on other sites More sharing options...
sasa Posted August 13, 2008 Share Posted August 13, 2008 try <?php $ok = array(); array_push($ok, "value1"); while ($value=each($ok) and $i++ <9) { array_push($ok, "value2"); print $value[1]; } ?> Link to comment https://forums.phpfreaks.com/topic/119465-solved-array-probllem/#findComment-615416 Share on other sites More sharing options...
Panjabel Posted August 13, 2008 Author Share Posted August 13, 2008 thanks, you saved my day Link to comment https://forums.phpfreaks.com/topic/119465-solved-array-probllem/#findComment-615450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.