-3
如何在php上使用正則表達式檢測數學運算符上的所有符號?如何在php上使用正則表達式檢測數學運算符上的所有符號?
例如:
$operators = [">0",">=1","==12","<9","<=1","!=4"];
$results = array();
foreach ($operators as $key => $value){
detect $value using regex, if include symbol of maths operators {
array_push($results, $value);
// just push $value with format of symbol of maths operators, example : ">" // remove 0 on my string
}
}
從我的陣列我想收集只是數學運算符,我的預計業績:
$results = [">",">=","==","<","<=","!="];
如何做到這一點? 謝謝先進
只是使用'array_map'和'preg_replace'功能.. – check