Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   preg_replace error - may be fixed (http://www.go4expert.com/forums/pregreplace-error-fixed-t23635/)

David Ledger 21Oct2010 16:52

preg_replace error - may be fixed
 
I have PHP 5.3.2 on my Mac, but my ISP has PHP 5.2.9

I'm looking for confirmation of my problem in 5.2.9 so that I can try to get my ISP to upgrade.

I see the problem on my site at the ISP, but not with interactive php use on my Mac.

The problem:

Code: PHP

Apply
preg_replace('/^[^\%]*(\%[^\%]+\%).*/', '$1', $cell)
where $cell contains (there is a single space at beginning and end)
 valign="top" style="text-align:right; width:75px;"><p class="f-lp">%Price%</p>
and you get
%Price%
but if $cell contains (there is a single space at beginning and end)
 valign="top" style="text-align:right; width:75px;"><p class="f-lp">%LineTotal%</p> </td>
then you get
%LineTotal% </td>
(which has a space on the end).


I've tried various fiddles and variants, but can't get rid of the trailing <space></td> in the second case when using my ISP's PHP.

Please forgive the mix of code and non-code in the CODE block.

David


All times are GMT +5.5. The time now is 20:11.