How to change the color of the first character of every word in a string with PHP

1 Answer

0 votes
$s = 'PHP Java C++ Python';
$s = preg_replace('/(\b[a-z])/i','<span style="color:blue;">\1</span>', $s);
echo $s;

 
/*
run:
 
PHP Java C++ Python
 
*/



answered Feb 22, 2019 by avibootz
...