问题
If I want to operate with a $tokens array it always happens nothing. An example code:
$input = array("⋃","⋃","a","⋃","h");
$impl = implode($input);
$impl = preg_replace('/⋃{2}/u','$0|',$impl);
preg_match_all('~\X~u', $impl, $tokens);
$akzent = array("´");
$result = array_pop($tokens);
echo print_r($result);
Is it because $tokens is not a normal array?
回答1:
The $tokens here is an array of arrays. That is why you need to access all the matches in the first subarray, $tokens[0]. Modify the part of the code like this:
preg_match_all('~\X~u', $impl, $matches);
$tokens = $matches[0];
$result = array_pop($tokens);
See the PHP demo
来源:https://stackoverflow.com/questions/41027075/tokens-array-does-not-change-at-all