Jump to content

how does one remove everything after a + in a php string?


jonaofarc

Recommended Posts

You're not very specific. Under what conditions would you get a string like that? There are many ways, some regex based, some not. At it's simplest I'd use

 

$text = '4+1';
$text = substr($text, 0, 1);

 

or

 

$text = '4+1';
$text = current(explode('+', $text));

 

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.