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?
system
August 18, 2003, 7:31pm
2
I’m sorry I don’t really understand what you’re trying to do… it doesn’t make sense to me…
system
August 19, 2003, 4:39pm
3
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!
system
August 19, 2003, 6:50pm
4
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);
system
August 20, 2003, 5:56am
5
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!
system
August 20, 2003, 6:01am
6
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);
system
August 20, 2003, 6:57am
7
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!