Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It is not ouputting values in array when echoed

Tags:

php

I think there is a problem when I echo $whereArray and orderByArray. If I type in a word such as "Question" and then submit it, I expect it to display in the echos "%".Question."%"; for both arrays. But instead in both echos it just displays "Array" for both echos. Does this mean that both arrays are not working when it comes to storing in the values?

 $searchquestion = $_GET['questioncontent'];
    $terms = explode(" ", $searchquestion);

$whereArray = array();
$orderByArray = array();


    //loop through each term
    foreach ($terms as $each) {
        $i++;
        $whereArray[] = "%".$each."%";
        $orderByArray[] = "%".$each."%"; 


    }

        echo $whereArray;
        echo $orderByArray;
like image 492
user1394925 Avatar asked Nov 29 '25 08:11

user1394925


1 Answers

echo() only works for strings. PHP converts your array to "Array" as a fallback.

When you're debugging, you should use var_dump(). It will tell you the type of the object and its content.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!