I have the following array $myarr and the $url value as such :
$url = "http://www.example.com/jane-doe/testingideas.html";
stdClass Object
(
[items] => Array
(
[0] => stdClass Object
(
[updated] => 2015-01-08 17:22:23.279210
[url] => http://www.example.com/jane-doe/testingideas.html
[score] => 21.053322
)
[1] => stdClass Object
(
[updated] => 2015-01-08 17:22:23.279226
[url] => http://www.example.com/john-doe/ideas.html
[score] => 18.889984
)
)
)
The array has over 2000 values. I copied 2 to simplify things. I need to retrieve the score based on the URL. This is the code I wrote:
$myarr = $output->items;
foreach ($myarr as $val){
if ($val->url == $url ) {
$score = round($val->score);
} else $score = 'N/A';
}
This does not work because it doesn't find any scores, even when the URLs are matching.
I also trimmed both URLs to remove any whitespaces but I am having the same issue.