Q:

Write a PHP script to replace the first 'the' of the following string with 'That'

0

Write a PHP script to replace the first 'the' of the following string with 'That'.

Sample date: 'the quick brown fox jumps over the lazy dog.'

All Answers

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

<?php
$str = 'the quick brown fox jumps over the lazy dog.';
echo preg_replace('/the/', 'That', $str, 1)."\n"; 
?>

Sample Output:

That quick brown fox jumps over the lazy dog.

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