Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to replace any string using str_replace function in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 247
    Comment on it

    Hello Readers ,

    While doing web development many times we stuck with the concept of str_replace .

    For understanding this, let's suppose we have one email template file stored in project directory and when we going to replace any string dynamically we will str_replace.

    $file_output = file_get_contents("xyz.come/emails/my_email_template.php");
    

    In that file we have one string call {NAME} and we want to replace that to dynamically coming Name so we will use str_replace that time.

    $file_output=str_replace('{NAME}', 'foobar', $file_output);
    

    So in this way we can replace any string in our template using str_replace.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: