I am unable to have the array_search() working.
I have a string from an API call in a variable $myresp
[{"name":"product 1","order_id":1,"product_type":"new","qty_ordered":1,"sku":"8057","scaffale":"B-21-B"},{"name":"Product 2","order_id":1,"product_type":"old","qty_ordered":1,"sku":"8057","scaffale":"B-21-B"}]
I then use $mydata = json_decode($myresp); to get an array format
Using print_r($mydata); returns me
Array ( [0] => stdClass Object ( [name] => Product 1 [order_id] => 1 [product_type] => new [qty_ordered] => 1 [sku] => 8057 [scaffale] => B-21-B ) [1] => stdClass Object ( [name] => Product 2 [order_id] => 1 [product_type] => old [qty_ordered] => 1 [sku] => 8057 [scaffale] => B-21-B ) )
If I try using echo array_search("new", $mydata); I am expecting to get the value of the key of the array tha contains value = new (in this case array 0) .
Unfortunately is doing nothing.
What am I doing wrong?