Jump to content

having trouble making data csv safe


kts

Recommended Posts

In the description field, I have bullets and such. I have used strip_tags and other methods of replace to remove this, but it continues happening. Has anyone had any similar problems that they have solved?

 

Shows up like

O  Blah blah blah

O  Blah blah blah

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/144082-having-trouble-making-data-csv-safe/
Share on other sites

Try preg_replace?

 

$string = preg_replace('/[^\w\d]/', '', $string);

 

Note: This is a very aggressive replace and will replace anything that is not a word and not a number.

 

It also takes a lot longer than the standard string replace methods and is a last resort in standard cases (personally)

it has gotten quite messy, been pulling out all stops haha

 

 

function csvsafe($str=''){
return '"'.trim(str_replace('"','\'',$str)).'"';  
}

$description = ''.strip_tags(csvsafe(strip_tags(str_replace(chr(13)," ",str_replace(chr(10)," ",($desc['value']))))));
$data .= str_replace($search, $replace, $description).','; 

Sorry for the delay found out more the actual text is this

 

Product Features:

O	Piston-driven Microprocessor

O	Adjustable Speed Settings

O	Adjustable Suction Knobs From 0 - 250 MmHg.

O	Built-in Bottle Holders

O	Breast Pump

O	Includes 12 V Car Adapter, Hospital Grade Cord

O	Designed For Medical Facilities Or Moms Of Twins

 

and that is how it is coming out, im trying to remove the O          etc etc etc and just make it plain text friendly

 

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.