cheadirl Posted January 19, 2007 Share Posted January 19, 2007 Hi ,I've been trying to figure this one out and I'm stumped ! I have a .csv file that contains a lot of data and is auto uploaded to a DB, problem is there is no formatting on the fields.So I have a field of this :aghahafgfhfhafgafhkafhfha </TEXT I WANT/> lsgfslgjfasghsjkldfhgsklgh </MORE TEXT I WANT/>I dont think str_replace() will work for what I want to do - Im trying to only display the text inside the </ /> out onto my site, essentially removing the unwanted stuff. I do need to keep the unwanted in the DB just not displaying it on the page ?Does anyone have any idea how I might get this to work ?ThanksCheadIRL Link to comment https://forums.phpfreaks.com/topic/34896-removing-unwanted-text/ Share on other sites More sharing options...
dgiberson Posted January 19, 2007 Share Posted January 19, 2007 You could use a regular expression to do this.... Link to comment https://forums.phpfreaks.com/topic/34896-removing-unwanted-text/#findComment-164529 Share on other sites More sharing options...
cheadirl Posted January 22, 2007 Author Share Posted January 22, 2007 Sorry dont get what you mean - I've looked all over for the answer to this - I've got a script that will extract text but not multiple times ! I need it to do that .If a regular expression will do any chance you could help me out with it ? Link to comment https://forums.phpfreaks.com/topic/34896-removing-unwanted-text/#findComment-166394 Share on other sites More sharing options...
Orio Posted January 22, 2007 Share Posted January 22, 2007 [code]<?php$txt = <<<DATAaghahafgfhfhafgafhkafhfha </TEXT I WANT/> lsgfslgjfasghsjkldfhgsklgh </MORE TEXT I WANT/>epogkpef </PART 3 of the text you want/>ieofewegwegewg</more info/>DATA;$regex = "/\<\/(.*?)\/\>/";preg_match_all($regex, $txt, $matches);$results = $matches[1];echo "<pre>";print_r($results);echo "</pre>";?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/34896-removing-unwanted-text/#findComment-166446 Share on other sites More sharing options...
cheadirl Posted January 22, 2007 Author Share Posted January 22, 2007 Hey,Thanks for this - worked a treat I've twaeked it a bit to grab results from a DB and do it with them all much appreciatedChead IRL Link to comment https://forums.phpfreaks.com/topic/34896-removing-unwanted-text/#findComment-166470 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.