Jump to content

How do I chop the end off of these phrases?


Jeffro

Recommended Posts

You don't need regex for this. You can just use explode:

 

$str = 'This-is-an-example-sentence-right-here';
echo implode('-', explode('-', $str, -3));

 

Note: This requires PHP 5.1.0 (when support for a negative limit parameter was added).

You don't need regex for this. You can just use explode:

 

$str = 'This-is-an-example-sentence-right-here';
echo implode('-', explode('-', $str, -3));

 

Note: This requires PHP 5.1.0 (when support for a negative limit parameter was added).

 

That could not have worked any better.  I expected a much longer solution.  THANK YOU!!!

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.