0

stristr($post['message'],$t1)=== FALSE gives a list of results but I need stristr($post['message'],$t1)=== TRUE, that gives only 1 result ! help plz.,

CODE:

 foreach($page_posts['data'] as $post){
        if(!(stristr($post['message'],$t1)=== FALSE) && $t1!==" ")
        { 
        $message = (($post['message']) ? $post['message'] : " ");
        $i++;
        print($message);
        }

same as stristr($post['message'],$t1)=== TRUE i.e.; gives one result only ~

1
  • what are you trying to do, and what is $t1? Commented Dec 19, 2013 at 0:04

2 Answers 2

2

stristr will NOT return boolean TRUE... it will return string when the string you are looking for is found. Otherwise, it will return boolean FALSE.

http://www.php.net/stristr

so testing with stristr($post['message'],$t1)=== TRUE is wrong.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks I just want reverse operation of stristr($post['message'],$t1)=== FALSE , thats why I used '!' sign.
0

Use stripos, not stristr.

if(stripos($post['message'], $t1) > -1) {
  // needle is in haystack
}

2 Comments

then it's time you start echoing what's in $post['message'] and in $t1, and put that information in your question, to show those who might want to answer you what your data and needles are. Because this guaranteed works, which suggests your $t1 really doesn't exist in your data
that's great: so show us. update your question to show what's in $page_posts['data'], and what's in $t1, so that we can see the whole problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.