Home Forums Server-Side Replacing parameters in string

This topic contains 0 replies, has 1 voice, and was last updated by  sciens 2 years, 1 month ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #306

    sciens
    Keymaster

    Dear users,
    I have an array like this:

    $par['quantity'] = '10';
    $par['sender'] = 'Peter';
    $par['date'] = '12/12/2012';
    

    And a string like this:
    $str = ‘{$sender} sent you {$quantity} objects on {$date}’;
    I want to replace every {$variable} with $par[‘variable’]
    I know I have to use preg_replace()
    How can I do?
    Thanks

Viewing 1 post (of 1 total)

The topic ‘Replacing parameters in string’ is closed to new replies.