Jump to content

remove substring from end of string


Phear46

Recommended Posts

I want to remove the last ' AND' from my string im using to build a mySQL query. I thought using rtrim was the way to go but either im wrong or im not using it correctly:

foreach ($dupArray as $k => $v) {
			$whereStr = $whereStr . "$k='$v' AND ";
		}
		
		rtrim($whereStr, "AND");
		echo $whereStr;

Anyone got any ideas? I swear ive seen this done else where but i cant find any examples

Link to comment
https://forums.phpfreaks.com/topic/277930-remove-substring-from-end-of-string/
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.