Jump to content

[SOLVED] array probllem


Panjabel

Recommended Posts

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

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>";
?>

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.