Jump to content

[SOLVED] str_replace help!!!!


serbestgezer

Recommended Posts

I am trying to replace second character in the string with x when I use str_replace it replace it all "a" with x. Is there any way to replace

second character in the string?


<?php
$subject = "baaia";

$body = str_replace($subject[2], "x", $subject);

echo $body;
// bxxix

I want to print like "bxaia"

?>

 

Link to comment
https://forums.phpfreaks.com/topic/174960-solved-str_replace-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.