Jump to content

trim string after character


Stooney

Recommended Posts

If it´s only , (comma) and numbers after the | (pipe) char, you can do like this;

[code=php:0]$string = 'Rare|,0,12537';
$string = rtrim($string, '|,0..9');

echo $string;[/code]


Or like this:

[code=php:0]list($string) = explode('|', $string);[/code]


Or...

[code=php:0]$string = preg_replace('/\|.*/', '', $string);[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.