Problems with strpos() and while conditional

I´m using a code to find a string inside a text this way:

$vista_previa_traducida = "[url]this is an url[/url]"

while (strpos($vista_previa_traducida, "[url]") != false) {

    echo "I´m inside the conditional";


The code works fine but when the text starts with the string I´m finding, it doesn’t enter to the conditional. I don’t understand why, in this case the position is 0, so it should enter, but it doesn’t.

How can I fix this?

Try this and look out for the yellow warning box:

1 Like

Thanks! Worked with this:

strpos($vista_previa_traducida, "[url]") !== false

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.