hybmg57 Posted June 26, 2010 Share Posted June 26, 2010 Hi all, I've tried two ways but I cannot get this to work...Basically I'm trying to change the value strings in $row['GARAGEDESC'] to several human readable words... Below string is currently stored in $row['GARAGEDESC'] PARATTACHE,PAROPENER,PARREAR Below is the code... $Garage = $row['GARAGEDESC']; $search = array('[PARSWING]','[PARNONE]','[PARGOLFCAR]','[PARUNCOV]','[PARWKBENCH]','[PARUNASSIG]','[PAROVERSIZ]','[PARREAR]','[PARCOVERED]','[PARPORT-CH]','[PAROTHER]','[PAROPENER]','[PARDETACH]','[PARATTACHE]','[PARSIDE]','[PARCONVERS]','[PARASSIGN]','[PARTANDEM]','[PARSINK]','[PAROUT-ENT]','[PARFRONT]','[PARCIRCLE]'); $replace = array('Swing Drive','None','Golf Cart Garage','Uncovered','Workbench','Unassigned','Oversized','Rear','Covered','Porte-Cochere','Other','Opener','Detached','Attached','Side','Garage Conversion','Assign','Tandem Style','Has Sink in Garage','Outside Entry','Front','Circle Drive'); $msg=str_replace($search,$replace,$Garage); echo $msg; I've also tried this... str_replace("PARSWING","Swing Drive",$Garage); str_replace("PARNONE","None",$Garage); str_replace("PARGOLFCAR","Golf Cart Garage",$Garage); str_replace("PARUNCOV","Uncovered",$Garage); str_replace("PARWKBENCH","Workbench",$Garage); str_replace("PARUNASSIG","Unassigned",$Garage); str_replace("PAROVERSIZ","Oversized",$Garage); str_replace("PARREAR","Rear",$Garage); str_replace("PARCOVERED","Covered",$Garage); str_replace("PARPORT-CH","Porte-Cochere",$Garage); str_replace("PAROTHER","Other",$Garage); str_replace("PAROPENER","Opener",$Garage); str_replace("PARDETACH","Detached",$Garage); str_replace("PARATTACHE","Attached",$Garage); str_replace("PARSIDE","Side",$Garage); str_replace("PARCONVERS","Garage Conversion",$Garage); str_replace("PARASSIGN","Assign",$Garage); str_replace("PARTANDEM","Tandem Style",$Garage); str_replace("PARSINK","Has Sink in Garage",$Garage); str_replace("PAROUT-ENT","Outside Entry",$Garage); str_replace("PARFRONT","Front",$Garage); str_replace("PARCIRCLE","Circle Drive",$Garage); None of them are working... Any ideas???? Link to comment https://forums.phpfreaks.com/topic/205928-multiple-str_replace-not-working/ Share on other sites More sharing options...
premiso Posted June 26, 2010 Share Posted June 26, 2010 Well, the multiple str_replaces do not work because you never assign the replaced variable back to $Garage. The first one does not work because you have [ ] around the words in the replace array. Remove those brackets and it should work just fine for ya. Link to comment https://forums.phpfreaks.com/topic/205928-multiple-str_replace-not-working/#findComment-1077574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.