David
David

Reputation: 2721

how to extract the id from a string of specified pattern in php?

The string is like this:

"grade_value[]=2&grade_value[]=3&grade_value[]=4&grade_value[]=5"

how could i transform it to "grade_value in (2,3,4,5)"

Upvotes: 1

Views: 100

Answers (1)

Shakti Singh
Shakti Singh

Reputation: 86346

Assuming you are constructing where clause for mysql query.

parse_str($string, $output);
$values=implode(",",$output['grade_value']);
$str="grade_value in (".$values.")";

If that is not what you wanted please explain.

Upvotes: 2

Related Questions