Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

remove substring from end of string

$
0
0

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


Viewing all articles
Browse latest Browse all 13200

Latest Images

Trending Articles



Latest Images