sketchgal — 2013-04-29T09:02:24-04:00 — #1
I'm looking for a way to remove a price from the end of a paragraph of text.
I've looked at rtrim but I can't work out how to get it to find the £ sign and remove it plus everything to the right of this in a string!
Can anyone please help with this?
Thanks in advance!
cpradio — 2013-04-29T09:03:42-04:00 — #2
Can you provide examples of the paragraph you will receive and the output you expect?
sketchgal — 2013-04-29T09:14:42-04:00 — #3
Here's an example of the text I need to remove the price at the end from:
Tyre condition Good, Standard Features - Elektra cloth upholstery, Manual height adjustable front seats, Power assisted steering, Silver interior trim, Smokers pack, 16 double spoke alloy wheels style 222, BMW Business radio with single CD player, Solid paint, Reach + rake adjustable steering column, Body colour bumpers, Front head restraints, Dynamic brake control, Seat belt force limiter, Inflatable Tubular Structure head airbags for front/rear, 3 spoke sports leather steering wheel, 60/40 split rear seats, Driver/Passenger airbags (Impact dependent), Multifunction steering wheel with audio controls, Front isofix attachment + airbag deactivation, On board diagnostics, CBC - (Cornering brake control), Thatcham Category 1 alarm, Crash sensor, Front fog lights, Remote central locking, On board computer, Experian auto check clear. £10,250
cpradio — 2013-04-29T09:17:14-04:00 — #4
Okay, so if you know it will always be at the end, I'd suggest using substr with strrpos
$textWithoutPrice = substr($text, 0, strrpos($text, '£'));
sketchgal — 2013-04-29T09:24:16-04:00 — #5
Works perfectly! thanks for the help with this.