<?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";
preferences:
58.31 ms | 408 KiB | 5 Q