看起来您正在返回一个字符串。您可以做的是将字符串拆分为实例OR
并将其存储在数组中,然后遍历数组并拆分每个元素=
以隔离值。因此,如果您要在 PHP 中执行此操作,代码可能如下所示:
// For reasons of simplicity we will assume the result is stored in $result,
// and the leading [( and trailing )] have already been removed
$values = array();
$resultsplit = explode(' OR ', $result);
/* $resultsplit is now an array:
* $resultsplit[0] = "[depname]='mathematics'"
* $resultsplit[1] = "[depname]='electronics'"
* $resultsplit[2] = "[depname]='computer science'"
*/
if ($result != '') {
foreach ($resultsplit as $rs) {
$rsparts = explode('=', $rs);
/* $rsparts is now an array. On the first element:
* $rsparts[0] = "[depname]"
* $rsparts[1] = "'mathematics'"
* So all we need to do is stick $rsparts[1] into $values
*/
$values[] = $rsparts[1];
}
}
这会将所有值放入数组中$values
(包括开头和结尾的单引号)供您随意使用,无论有多少。如果 PHP 不是您可以使用的语言,那么同样的方法应该仍然可以在您选择的语言中使用。