Q:

Write a PHP script, which changes the color of the first character of a word

0

Write a PHP script, which changes the color of the first character of a word.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
$text = 'PHP Tutorial';
$text = preg_replace('/(\b[a-z])/i','<span style="color:red;">\1</span>',$text);
echo $text;
?>

Sample Output:

PHP Tutorial

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now