Q:

Write a PHP script to insert a string at the specified position in a given string

0

Write a PHP script to insert a string at the specified position in a given string.

Original String : 'The brown fox'
Insert 'quick' between 'The' and 'brown'

All Answers

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

<?php
$original_string = 'The brown fox';
$string_to_insert ='quick';
$insert_pos = 4;
$new_string = substr_replace($original_string, $string_to_insert.' ', $insert_pos, 0);
echo $new_string."\n";
?>

Sample Output:

The quick brown fox

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