الجمعة، 20 ديسمبر 2013

return true if strpos !== false

Right, for the 724th time I am missing something stupid here! I know how strpos works, and it is working as expected, but the return in the if function isn't.

Some code:

foreach ($socialstream as $key => $social) { //filtering in here $result= $this->search_objects($social); ....}

My function search_objects:

function search_objects($objects){ $filters = array('word', 'test'); foreach ($objects as $key => $value) { if (is_array($value) || is_object($value)) { $this->search_objects($value); } else { //look for faulty strings in value foreach ($filters as $filter) { if (!is_int($value) && strpos($value, $filter) !== false) { return true; } } } } return false;}

if I print out my $result, I always get false back, unstead of the true in the if function. I know it comes in the if when the needle exists in the haystack, by debugging, it's just not returning it.

soooo, what am I missing? I'm ashamed to have to ask this, but I'm looking at this for a full 2 days now, and deadline is getting close :/


View the original article here

ليست هناك تعليقات:

إرسال تعليق