preg_split
| From: | Mr Nik Frengle | Date: | Sun, 29 Dec 2002 07:23:34 +0000 |
| Subject: | preg_split | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-129575@lists.php.net to get a copy of this message | ||
I have the following code with a rather odd behaviour:
<html><head><title>Test></title></head><body>
<?php
$string='This is some text which will eventually need
to be split<p>
Hopefully it gets done here</p><p>
I would like that very much</p>
<p>but whether it will happen or not</p>
<p>is difficult to say.</p>';
$Xarray=preg_split('/(?=<p>)/',$string,-1,
'SPLIT_DELIM_CAPTURE');
$count=count($Xarray);
for ($i=0;$i < $count;){
print $Xarray[$i];
//print $i;
$i++;
}
?>
</body></html>
The behaviour is that on the last '<p>' delimiter that
is supposed to be returned instead returns 'p>',
leaving of the first '<'. Below is the source:
<html><head><title>Test></title></head><body>
This is some text which will eventually need to be
split<p>
Hopefully it gets done here</p><p>
I would like that very much</p>
<p>but whether it will happen or not</p>
p>is difficult to say.</p></body></html>
This was done as a test to figure out what was going
on. I am probably making some stupid newbie mistake,
but I have no idea what it is. Any ideas?
Best,
Nik
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com