How to trim some word in php? Example like
pid="5" OR pid="3" OR
I want to remove the last OR
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I suggest using
implode()to stick together SQL expressions like that. First build an array of simple expressions, then implode them with OR:Now
$sql_whereis the string'pid = "5" OR pid = "3"'. You don’t have to worry about leftover ORs, even when there is only one element in$pids.Also, an entirely different solution is to append
" false"to your SQL string so it will end in"... OR false"which will make it a valid expression.@RussellDias’ answer is the real answer to your question, these are just some alternatives to think about.