Search code examples
phpphp-5.2

Is there any function similar to stristr() in PHP 5.2


Is there any function similar to stristr()? I want to use stristr(), but I can't because my PHP version is 5.2.9.

So I need a similar function which gives the same functionality.

<?php
$email = '[email protected]';
echo stristr($email, 'e'); // outputs [email protected]
echo stristr($email, 'e', true); // As of PHP 5.3.0, outputs US
?>

How can i do this?


Solution

  • Use stripos and substr:

    echo substr($email, 0, stripos($email, 'e'));