Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6999769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:35:05+00:00 2026-05-27T20:35:05+00:00

Not very sure how to word this question but I’ll give an example. $string

  • 0

Not very sure how to word this question but I’ll give an example.

$string = 'Hey, $name. How are you?'; 

When I post this string, $name doesn’t change. How can I make it so I can put something like +name+ so it changes to the name. I’ve tried seaching for it but I don’t know what to search for so I don’t have any luck. It’s probably really simple but i’m just blanking out.
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:35:06+00:00Added an answer on May 27, 2026 at 8:35 pm

    You can use place-holders and str_replace. Or use PHP’s built-in sprintf and use %s. (And as of v4.0.6 you can swap the ordering of arguments if you’d like).

    $name = 'Alica';
    
    // sprintf method:
    $format = 'Hello, %s!';
    echo sprintf($format, $name); // Hello, Alica!
    
    // replace method:
    $format = "Hello, {NAME}!";
    echo str_replace("{NAME}", $name, $format);
    

    And, for anyone wondering, I understood that is trouble templating a string, not PHP’s integrated concatenation/parsing. I just assume keep this answer up though as I’m still not 100% sure this OP’s intent

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure if the title is very clear, but basically what I have
I know this is a very basic question, but I haven't been able to
not sure how to word this correctly.. so i have a view which has
I have seen a couple threads about this, but am not getting very straight
I am very very new to C/C++ and not sure what the method is
Not very technical, but... I have to implement a bad words filter in a
I am not very good with Regex but I am learning. I would like
I'm not very good at C, and I always get stuck on simple string
Not sure if the title makes sense sorry... basically I'm generating Word documents that
This question is very similar to that posed here . My problem is that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.