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 Quote 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>"; ?> Quote 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]; } ?> Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/119465-solved-array-probllem/#findComment-615450 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.