Jump to content

Removing &'s from parse.


303tech

Recommended Posts

I'm having problems when the string has &'s in it, as well as 's. I was able to remove the 's. But i get a return value of 0 when trying to do the same thing with &'s. If i take out the part where I'm trying to remove &, the value of $replace is OK.

 

//PARSE INI FILE.

$ini = parse_ini_file('config.ini');

 

//REMOVE APOSTROPHES FROM NAME.

$and="&";

$ini1=$ini['UNITNAME'];

$unitname=str_replace($and,"AND",$ini1);

echo $unitname;

$replace=str_replace("'","",$unitname);

echo $replace;

 

 

Also, is there a way that I can put chars like this in db fields?

Link to comment
https://forums.phpfreaks.com/topic/44559-removing-s-from-parse/
Share on other sites

//PARSE INI FILE.
$ini = parse_ini_file('config.ini');

//REMOVE APOSTROPHES FROM NAME.
$and="&";
$ini1=$ini['UNITNAME'];
$unitname=str_replace('&',"AND",$ini1);
echo $unitname;
$replace=str_replace("'","",$unitname);
echo $replace;

 

Try that. Not sure if it will work but it's worth a shot.

 

Link to comment
https://forums.phpfreaks.com/topic/44559-removing-s-from-parse/#findComment-216429
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.