Jump to content

Removing Unwanted Text


cheadirl

Recommended Posts

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 ?

Thanks
CheadIRL
Link to comment
https://forums.phpfreaks.com/topic/34896-removing-unwanted-text/
Share on other sites

[code]<?php

$txt = <<<DATA
aghahafgfhfhafgafhkafhfha </TEXT I WANT/> lsgfslgjfasghsjkldfhgsklgh </MORE TEXT I WANT/>
epogkpef </PART 3 of the text you want/>
ieof
ewegwegewg
</more info/>
DATA;

$regex = "/\<\/(.*?)\/\>/";
preg_match_all($regex, $txt, $matches);

$results = $matches[1];

echo "<pre>";
print_r($results);
echo "</pre>";

?>[/code]

Orio.

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.