How to insert a string inside another string?

Viewed 52324

Just looked at function

str_pad($input, $pad_length, $pad_str, [STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH])

which helps to pad some string on left, right or on both sides of a given input.

Is there any php function which I can use to insert a string inside an input string?

for example ..

$input = "abcdef";
$pad_str = "@";

so if I give insert index 3, it inserts "@" after first 3 left most characters and $input becomes "abc@def".

thanks

3 Answers
Related