0

$content gives the html code like:

<p>text</p>
<p><img ... /></p>
<div class="video">...</div>

or just

<p>text</p>
<p>more text</p>

Also we have a variable:

$video_match = false;

We should turn $video_match to true, if <div class="video"> (exactly this code) exists in $content.

Thanks.

1 Answer 1

5

Use:

if (strpos($content, '<div class="video">') !== FALSE)
{
  $video_match = true;
}

More Info:

Update:

Or more compact version as shown in the comments below:

$video_match = (strpos($content, '<div class="video">') !== FALSE);
Sign up to request clarification or add additional context in comments.

4 Comments

Simply this would do the job : $video_match = (strpos($content, '<div class="video">') !== FALSE);
$video_match = (strpos($content, '<div class="video">') !== FALSE);
@HoLyVieR: That's true but strictly it would return a number not true but anyway any number greater than 0 would still be considered true so yes that is a short way of doing it. Thanks
$video_match = (strpos($content, '<div class="video">');

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.