$tokens 数组根本没有改变 [英] $tokens array does not change at all

查看:42
本文介绍了$tokens 数组根本没有改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想用 $tokens 数组 操作,它总是什么也不会发生.示例代码:

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);

是不是因为$tokens 不是普通数组?

Is it because $tokens is not a normal array?

推荐答案

这里的 $tokens 是一个数组.这就是为什么您需要访问第一个子数组 $tokens[0] 中的所有匹配项.修改部分代码如下:

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);

查看 PHP 演示

这篇关于$tokens 数组根本没有改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆