Stooney Posted November 21, 2006 Share Posted November 21, 2006 last post today, i promise...how would i trim the data off this string after '|'Rare|,0,12537 should come out to just Rare, with the | and on being trimmed. Link to comment https://forums.phpfreaks.com/topic/27927-trim-string-after-character/ Share on other sites More sharing options...
Nicklas Posted November 21, 2006 Share Posted November 21, 2006 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] Link to comment https://forums.phpfreaks.com/topic/27927-trim-string-after-character/#findComment-127724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.