Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Smarty,计算数组键字符串的长度?_Php_Count_Smarty - Fatal编程技术网

Php Smarty,计算数组键字符串的长度?

Php Smarty,计算数组键字符串的长度?,php,count,smarty,Php,Count,Smarty,{$smarty.post.email}输出”john@yahoo.com" {$smarty.post.email | count}输出“1”而不是“14”——字符串长度 {$smarty.post.email[0]| count}也输出“1” 如何查找名为“电子邮件”的密钥的长度 strlen返回字符串的长度。键名是字符串 count返回数组中的键数 使用 来源:不只是{$smarty.post.email | strlen}有用吗?我忘了提到它的smarty v2,它确实有用!我忘了检查我

{$smarty.post.email}
输出”john@yahoo.com"

{$smarty.post.email | count}
输出“1”而不是“14”——字符串长度

{$smarty.post.email[0]| count}
也输出“1”

如何查找名为“电子邮件”的密钥的长度

strlen返回字符串的长度。键名是字符串

count返回数组中的键数

使用


来源:

不只是
{$smarty.post.email | strlen}
有用吗?我忘了提到它的smarty v2,它确实有用!我忘了检查我是否记得我一直在寻找计算字符串长度的方法,并且从未尝试过斯特伦解决方案。谢谢你!如果你能选择一个答案来结束这个问题,那就太酷了。你可以回答你自己的问题,或者我可以添加我的评论作为答案。我有smarty v2 |@count返回数组中的键数| count返回我假设的单变量非数组中的字符数。strlent()php函数应该是什么?我不喜欢在smarty模板中使用php代码。老实说,我不知道smarty是什么。我以为你的意思是“聪明”。如果您使用的是php,我不知道使用strlen会有什么缺陷,但我可能弄错了。你试过了吗,至少看看它是否有效?
$count = strlen($smarty.post.email);

$count = strlen($smarty[post][email]);
{$smarty.post.email|count_characters:true}