Re: RIGHT Function?
| From: | sono-io at fannullone dot us | Date: | Sun, 15 Nov 2009 00:00:47 +0000 |
| Subject: | Re: RIGHT Function? | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-299834@lists.php.net to get a copy of this message | ||
On Nov 13, 2009, at 6:34 PM, Jim Lucas wrote:
You basic problem with the PHP_EOL is that when echo'ed out, it represents a \n character. The value you are working with might be \n\r or just \rI read the links you sent, plus some others. It took me awhile, but I get it now. If the "return character" that was entered into that field is not the same as what PHP_EOL is looking for, it won't work.
$parts = preg_split('|[\n\r]+|', $item['unitprice']);preg_split works perfectly! Very similar to Perl's split function. Here's what I have now: $parts = preg_split('|\s+|', $item['unitprice']); $price = '$'.number_format((count($parts) > 1) ? $parts[(count($parts)-1)] : $parts[0],2); Clean and concise. Thanks a million, Jim! I really appreciate your helpful responses. Thanks again, Frank