Jim,

$parts = explode(PHP_EOL, $item['unitprice']);

$price = '$'.(( count($parts) > 1 ) ? $parts[0] : $parts[(count($parts)-1)]);

For some reason, I couldn't get explode to work with PHP_EOL. $parts[0] would return the entire field, so apparently it wasn't "exploding". So I tried exploding on the ')' instead, which worked, but the return character that's after the ')' was included in the output, i.e.:
$
6.56

so I added 'trim' which took care of that. I also had to use 'number_format' again, since there are exact dollar amounts like 413. Here's what ended up working for me:

$parts = explode(')', $item['unitprice']);
$price = '$'.number_format(trim((( count($parts) > 1 ) ? $parts[(count($parts)-1)] : $parts[0])),2);


Any idea why PHP_EOL didn't work? If I could get it to work, I could remove the trim function and 2 of those parentheses, which would look a lot nicer.

Thanks again,
Frank

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to