我正在制作一种方法,因此您的密码至少需要一个标题和一个符号或数字.我正在考虑将字符串拆分为丢失字符,然后使用preggmatch计算它是否包含一个大写和符号/数字.
但是我在动作脚本中做了类似的事情,但无法弄清楚如何在php中调用它.我无法找到一种方法将一个单词的每个字符串放在一个数组中.
AS3的例子
for(var i:uint = 0; i < thisWordCode.length -1 ; i++)
{
thisWordCodeVerdeeld[i] = thisWordCode.charAt(i);
//trace (thisWordCodeVerdeeld[i]);
}
Run Code Online (Sandbox Code Playgroud)
谢谢,Matthy
PHP中的函数调用很昂贵.这是一个测试它的小基准:
<?php
const RUNS = 1000000;
// create test string
$string = str_repeat('a', 1000);
$maxChars = 500;
// with function call
$start = microtime(true);
for ($i = 0; $i < RUNS; ++$i) {
strlen($string) <= $maxChars;
}
echo 'with function call: ', microtime(true) - $start, "\n";
// without function call
$start = microtime(true);
for ($i = 0; $i < RUNS; ++$i) {
!isset($string[$maxChars]);
}
echo 'without function call: ', microtime(true) - $start;
Run Code Online (Sandbox Code Playgroud)
这使用函数first(strlen)测试功能相同的代码,然后不使用函数(isset不是函数).
我得到以下输出:
with function …Run Code Online (Sandbox Code Playgroud)