Try the following,
array_push(yourarray, rtrim(array_pop(yourarray), ' **and**'and'));
It will pop the last element, trim away the and" and" at the end and then re-add itthe modified element to the array.
ExampleFor example,
$yourarray = array("date = '2012-02-22' and time ='08:49' and",
"date = '2012-02-22' and time ='08:49' and ");
var_dump($yourarray);
array_push($yourarray, rtrim(array_pop($yourarray), ' **and**'and'));
var_dump($yourarray);
Outputsoutputs the following
array(2) {
[0]=>
string(41) "date = '2012-02-22' and time ='08:49' and"
[1]=>
string(42) "date = '2012-02-22' and time ='08:49' and "
}
array(2) {
[0]=>
string(41) "date = '2012-02-22' and time ='08:49' and"
[1]=>
string(37) "date = '2012-02-22' and time ='08:49'"
}
So, the last and" and" in the last element ishas been removed.