Answers for "php get first word"

PHP
1

get first word from string php

function getFirstWord($string)
    {
        $arr = explode(' ', trim($string));
        return isset($arr[0]) ? $arr[0] : $string;
    }
Posted by: Guest on February-26-2021
0

php get first character of each word

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;
    }
}
Posted by: Guest on August-30-2021
0

get firstwod php

$dis=$mysqli->query("select * from article");
while ($diss = $dis->fetch_assoc()) {
 
  $t=$diss['title'];

$abbreviation = explode(' ', trim($t ))[0];
echo $abbreviation; 
echo'</br>'; // will print Hello 
}
Posted by: Guest on October-19-2021

Code answers related to "php get first word"

Browse Popular Code Answers by Language