I have an array that is like
Array([GOOG] => 1, [AAPL] => 2);
How can I do a foreach where I can grab the value like GOOG (the list is ordered by the number value)
Thanks,
Fred
Foreach help
-
- Posts: 205
- Joined: Mon Jul 09, 2012 11:13 pm
Re: Foreach help
It's actually a lot simpler than one would think Here's an example.
[syntax=php]<?php
$array = array("Test" => "successful"); // Just a sample array
foreach($array as $key => $value) {
echo $key." returned ".$value; // Displays "Test returned successful"
}
?>[/syntax]
[syntax=php]<?php
$array = array("Test" => "successful"); // Just a sample array
foreach($array as $key => $value) {
echo $key." returned ".$value; // Displays "Test returned successful"
}
?>[/syntax]
<?php while(!$succeed = try()); ?>