3v4l.org

run code in 300+ PHP versions simultaneously
<?php // let's say I want to add "Has" at beginning (if doesn't exist) $string_1 = "AnaHasSomeApples"; // we need to add $string_2 = "HsSomeApples"; // we need to add $string_3 = "HasApplesAlready"; // already exists at the beginning echo "string_1: ". (strpos($string_1,"Has") !== 0 ? "Has".$string_1: $string_1)."\n"; echo "string_2: ". (strpos($string_2,"Has") !== 0 ? "Has".$string_2: $string_2)."\n"; echo "string_3: ". (strpos($string_3,"Has") !== 0 ? "Has".$string_3: $string_3)."\n";

preferences:
16.88 ms | 404 KiB | 5 Q