How To Assigning A New Character In A String Using PHP

How To Assigning A New Character In A String Using PHP


  • 16 Mar, 2013

    we can use str_replace function. 

    Ex:

    $string = 'Hello';

    $alteredString = str_replace('e', 'i', $string);

    echo $alteredString;

    O/P : Hillo

    Comments Received:
    Please give your suggestions and feedback:
  • 12 Mar, 2012

    The string element expression, $string{index}, can also be used at the left side of an assignment statement. This allows you to assign a new character to any position in a string. Here is a PHP script example:<?php $string = 'It's Friday?';echo "$string";$string{11} = '!';echo "$string";?>This script will print:It's Friday?It's Friday!

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.