Get first character of string: Difference between revisions

Created page with " == PHP == Using the [https://www.php.net/manual/en/function.substr.php PHP: substr] function<ref>[https://www.php.net/manual/en/function.substr.php PHP: substr - Manual]</re..."
 
mNo edit summary
Tag: wikieditor
 
Line 5: Line 5:


<pre>
<pre>
echo substr('apple', 0, 1);
 
$string = 'apple';
if (function_exists('mb_substr')) {
            echo mb_substr($string, 0, 1, 'UTF-8');
}
echo substr($string, 0, 1);
// return 'a'
// return 'a'
</pre>
</pre>