Print array values separately
I created an array in php that prints this
Array ( [mark] => Array ( [0] => 3 [1] => 4 ) )
How can I print the marks separately from the array. for example just print 3.
+3
John smith
source
to share
3 answers
Assuming $array
- your array:
echo $array['mark'][0];
+6
Dogbert
source
to share
to print all values:
foreach($array as $value){
echo $value."<br />";
}
+1
safrazik
source
to share
$myArray = array('mark'=>array(3, 4));
You can print a specific element using for example:
echo $myArray['mark'][0]; // this would print out 3
You can also loop through the array:
foreach($myArray['mark'] => $item) {
echo $item;
}
// this would result it the printing of 3 first and then 4
+1
PeeHaa
source
to share