string - How to print array value into non array value using php

64

For Example :-

print_r($matches);

**output:**  Array ( [0] => Array ( [0] => 5000 ) )

BUT

If I use echo,

echo ($matches)

**output:** Array

How do I only print the values?

277

Answer

Solution:

in your case, you need to use

echo $matches[0][0];

Most questions like this are answered in the php manual though

Example #6 Accessing array elements from http://www.php.net/manual/en/language.types.array.php

148

Answer

Solution:

foreach($matches as $match) {
    echo $match;
}

In your example you have an array in an array. Access the values like this then:

foreach($matches as $match) {
    foreach($match as $secondMatch) {
        echo $secondMatch;
    }
}

Like this you iterate through the array and print each entry with echo. But you could just google "php array"

People are also looking for solutions to the problem: php - #1452 - Cannot add or update a child row, REFERENCES `eav_attribute`

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.