How to get all first character in sentences using PHP? -


what want first character in sentences, knew substr can this, substr able 1 character.

i use code now, h instead of hw

substr($string,0,1); 

what want is

$string = "hello world"; $result = "hw"; 

any idea how ?

thanks

$string = 'hello, world!'; $result = ''; foreach (preg_split('#[^a-z]+#i', $string, -1, preg_split_no_empty) $word) {     $result .= $word[0]; } var_dump($result); 

demo: https://eval.in/158045


Comments

Popular posts from this blog

ios - Change Storyboard View using Seague -

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -