3

I have created an array in php that prints this

Array ( [mark] => Array ( [0] => 3 [1] => 4 ) )

How i can print the marks separately from the array. e.g just print out 3.

3 Answers 3

6

Assuming $array is your array:

echo $array['mark'][0];
Sign up to request clarification or add additional context in comments.

Comments

1

to print all values:

foreach($array as $value){
 echo $value."<br />";
}

Comments

1
$myArray = array('mark'=>array(3, 4));

You can print a specific element by using for example:

echo $myArray['mark'][0]; // this would print out 3

You could also loop through the array:

foreach($myArray['mark'] => $item) {
    echo $item;
}

// this would result it the printing of 3 first and then 4

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.