Jump to content

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.