php loop array key value code example
Example 1: php for array key value
<?php
$array = array(1=>"apple",2=>"Orange",3=>"Banana");
foreach($array as $key => $value){
echo "The value for " . $key . " is " . $value;
}
?>
Example 2: foreach ph
<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
$value = $value * 2;
}
unset($value);
?>
Example 3: php loop object keys
echo $obj->name;
echo $obj->age;
Example 4: php loop through array
foreach (array_expression as $value)
statement
foreach (array_expression as $key => $value)
statement