Jump to content

Remove last word


aeroswat

Recommended Posts

like so?

 


$test='this is a test string';
	$ar=explode(' ',$test);
	$ar[count($ar)-1]='';

	$new=implode(' ',$ar);

	echo $new; // gives 'this is a test'

	exit;

 

ya. I thought there might have been some functions that easily handled this other than breaking the string down into an array of space delimited strings and then piecing it back together. Thank you tho

Link to comment
https://forums.phpfreaks.com/topic/193141-remove-last-word/#findComment-1017079
Share on other sites

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.