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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.