Problem in reading from Array in 'foreach'
Posted: Fri Apr 09, 2010 5:37 pm
What exactly where you trying to do here?
Code: Select all
array ($finaltot[$j] = $row);A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
array ($finaltot[$j] = $row);Code: Select all
$final = $value* $totElectrici;Code: Select all
$finaltot[$j] = $row2 ways. If the array is keyed by names, you can reference by the key name or key index:Shamma009 wrote:how can I get the value out of the array ?
Code: Select all
$userInfo = array('name' => 'john', 'birthday' => '1985-08-23', 'town' => 'jacksonville');
$name = $userInfo['name'];
$birthday = $userInfo['birthday'];
// $name and $birthday will be the same if you do it this way:
$name = $userInfo[0];
$birthday = $userInfo[1];
Code: Select all
$errorMessages = array('Invalid username or password', 'Email address is not valid', 'Your session has expired, please log in again.');
$firstError = $errorMessages[0];
$secondError = $errorMessages[1];
foreach ($errorMessage as $error) {
echo 'The error received was: ' . $error;
}