|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Ereg Replace Function
Hi All ..
I want to replace my string with ereg_replace, but i get error the script look like this : --------- $temp = "Name : {NAME}<br>"; $temp .= "Home : {HOME}"; $my_arr = array("NAME" => "Deff", "HOME" => "Casablankca"); while(list ($key,$val) = each($my_arr)) { $data = ereg_replace("$key","$val","$temp"); } echo $data; --------- and the result is : Name : {NAME} Home : {Casablankca} but i want the result is : Name : Deff Home : Casablankca what's wrong with my script? how do i fix the error? thank's --deff Last edited by deff_lee : June 4th, 2002 at 03:09 AM. |
|
#2
|
|||
|
|||
|
Sounds simple, but if you only have one name/value pair then just use str_replace instead:
$temp = "Name : {NAME}<br>"; $temp .= "Home : {HOME}"; $my_arr = array("NAME" => "Deff", "HOME" => "Casablankca"); str_replace($temp, "{NAME}", $my_arr["NAME"]); str_replace($temp, "{HOME}", $my_arr["HOME"]); |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Ereg Replace Function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|