Ciao ragazzi ho un problema con la funzione BBCODE che utilizzavo


funzione corretta:

Codice PHP:
function bbcode($text){

    
$text trim(str_replace("#Number""12345"$text));
    
$text trim(str_replace("#Name""XXX"$text));
    
$text trim(str_replace("#Payment""Paypal"$text));
    
$text trim(str_replace("#CostShipping""10.25"$text));
    
$text trim(str_replace("#Total""125.56"$text));
    return 
$text;

}

$str "Numero:#Number, Nome:#Name, Pagamento:#Payment, Costo spedizione:#CostShipping, Totale:#Total";

echo 
bbcode($str); 

Adesso se invece devo sostiture i vari tag #Name ecc. facendo in questo modo non mi converte i tag nei valori presenti nelle variabili, c'è un modo per fargli leggere le variabili impostate?


Codice PHP:
$a1 "12345";
$a2 "XXX";
$a3 "Paypal";
$a4 "10.25";
$a5 "125.56";

function 
bbcode($text){

    
$text trim(str_replace("#Number"$a1$text));
    
$text trim(str_replace("#Name"$a2$text));
    
$text trim(str_replace("#Payment"$a3$text));
    
$text trim(str_replace("#CostShipping"$a4$text));
    
$text trim(str_replace("#Total"$a5$text));
    return 
$text;

}

$str "Numero:#Number, Nome:#Name, Pagamento:#Payment, Costo spedizione:#CostShipping, Totale:#Total";

echo 
bbcode($str);