php dapatkan karakter string pertama
$firstStringCharacter = substr("hello", 0, 1);
Grepper
$firstStringCharacter = substr("hello", 0, 1);
$words = explode(" ", $string);
$firstname = $words[0];
$lastname = $words[1];
$third_word = $words[2];
function getFirstWord($string)
{
$arr = explode(' ', trim($string));
return isset($arr[0]) ? $arr[0] : $string;
}
if(!function_exists('get_avatar')){
function get_avatar($str){
$acronym;
$word;
$words = preg_split("/(\s|\-|\.)/", $str);
foreach($words as $w) {
$acronym .= substr($w,0,1);
}
$word = $word . $acronym ;
return $word;
}
}
$value = "Test me more";
echo strtok($value, " "); // Test