Home Forum Server-Side Replacing parameters in string

Questo argomento contiene 0 risposte, ha 1 partecipante, ed è stato aggiornato da  prova fdss 5 anni, 10 mesi fa.

Stai vedendo 1 articolo (di 1 totali)
  • Autore
    Articoli
  • #306

    prova fdss
    Amministratore del forum

    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

Stai vedendo 1 articolo (di 1 totali)

La discussione ‘Replacing parameters in string’ è chiusa a nuove risposte.