I want to show some data from JSON string by making that string to array
I have used json_decode to convert the json string into an array. Here is my json string (dd):
"{"title":"W3Schools Online Web Tutorials","description":"w3schools.com","image":"http:\/\/www.w3schools.com\/images\/colorpicker.png","url":"https:\/\/www.w3schools.com\/"}"
When I am returning the array or dd the array, that showing me the array as I intended (dd):
array:4 [▼"title" => "W3Schools Online Web Tutorials""description" => "w3schools.com""image" => "http://www.w3schools.com/images/colorpicker.png""url" => "https://www.w3schools.com/"]
But then when I am trying to show $myarray->title
it is giving me error:
Trying to get property 'title' of non-object
public function showDetail(Request $request){
$rUrl = "http://api.linkpreview.net/?key=5c59318d927ca5c5b481c89a6c18a0a2623a61d568502&q=".$request->body;
$json_string= file_get_contents($rUrl);
$data= json_decode($json_string,true);
return view('showIn')->with('data', $data);
}
Expected result: W3Schools Online Web Tutorials
Actual result: Error:Trying to get property 'title' of non-object