PDA

View Full Version : eregi_replace issue!



andr.in
August 18th, 2003, 02:33 PM
I am loading text from a .txt file!

$NewsTxT = fread($fp, 10240);

I want to cut out some text from the beginning and make the cut-version $Oldtext


$Oldtext = eregi_replace('&newsTxT=<div align="center">(.*)</div><br><br><p align="left">News:<br><br><b>-', '', $NewsTxT);
//This part works perfectly!
And then I would like to have a variable $WelcomeTxT to have the value of the text that was cut out from the previous variable!

$WelcomeTxT = eregi_replace($Oldtext, '', $NewsTxT);
So it cuts out the rest of the text from the original text!

But for some reason it's not working! $WelcomeTxT has the same value as $NewsTxT!

Any ideas? Or any other wasy of doing this?

Jubba
August 18th, 2003, 03:31 PM
I'm sorry I don't really understand what you're trying to do... it doesn't make sense to me...

andr.in
August 19th, 2003, 12:39 PM
doh'! :|

ok...

I want $Oldtext to be everything that $NewsTxT is except this line:



'&newsTxT=<div align="center">(.*)</div><p align="left">News:<b>-'

so I used eregi_replace to cut it out from there!

Now I want $WelcomeTxT to be the text that was cut out before from $Oldtext

(this piece: '&newsTxT...">News:< b>-')

so I used eregi_replace to cut the rest of the text ($Oldtext) out of the full original text($NewsTxT) but it's not working!The last eregi_replace doesn't work!

Jubba
August 19th, 2003, 02:50 PM
well if you know what you want that text to be, why don't you just do this:



$welcomeTxt = '&newsTxT=<div align="center">(.*)</div><p align="left">News:<b>-';

$oldTxt = ($welcomeTxt, "", $newTxt);

andr.in
August 20th, 2003, 01:56 AM
hmh... I would do that! but you see "(.*)" in $WelcomeText that means any number of any symbols between the 2 text..s! And the thing is that I want it to display it in a textarea in a from andI want it to be changeable! So if I change it wouldn't have to change the php script!

Jubba
August 20th, 2003, 02:01 AM
well you would have to have the script do that anyway because of the way you had it set up originally...


//doing this...
$Oldtext = eregi_replace('&newsTxT=<div align="center">(.*)</div><p align="left">News:<b>-', '', $NewsTxT);

// is the same as doing this:
$welcomeText = '&newsTxT=<div align="center">(.*)</div><p align="left">News:<b>-';
$oldText = eregi_replace($welcomeText, '', $newText);

andr.in
August 20th, 2003, 02:57 AM
humm... I think you're right but I just found a better way to do this with fake html tags in the txt file explode() and an array!
Thanx anyways! :)

Jubba
August 20th, 2003, 10:27 AM
good deal :)