3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = "Lorem IPSUM dolor sit amet, consectetur ipsum adipiscing elit."; $dolor = substr($a, 12, 5); echo "substr from position 15, 5 characters => ".$dolor."\n"; $elit = substr($a, -5, 4); echo "substr from position -5, 4 characters => ".$elit."\n"; // case sensitive $dolor_position = strpos($a, "dolor"); echo "strpos of dolor (case sensitive) => ".$dolor_position."\n"; // case insensitive $dolor_position_i = stripos($a, "dOLor"); echo "stripos of dOLlor (case insensitive) => ".$dolor_position_i."\n"; // case sensitive $new_a = str_replace("ipsum", "hello", $a); echo "str_replace ipsum (case sensitive) with hello => ".$new_a."\n"; // case insensitive $new_a = str_ireplace("ipsum", "hello", $a); echo "str_replace ipsum (case insensitive) with hello => ".$new_a."\n"; $len = strlen($a); echo "strlen (length) of a => ".$len."\n";
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
substr from position 15, 5 characters => dolor substr from position -5, 4 characters => elit strpos of dolor (case sensitive) => 12 stripos of dOLlor (case insensitive) => 12 str_replace ipsum (case sensitive) with hello => Lorem IPSUM dolor sit amet, consectetur hello adipiscing elit. str_replace ipsum (case insensitive) with hello => Lorem hello dolor sit amet, consectetur hello adipiscing elit. strlen (length) of a => 62

preferences:
177.79 ms | 404 KiB | 210 Q