Home  >  Article  >  Backend Development  >  下面这段如何理解

下面这段如何理解

WBOY
WBOYOriginal
2016-06-13 12:09:59816browse

下面这段怎么理解
$str="1234567890";
$s='';

for($i=0;$i{
    $k=mt_rand(1, strlen($str));
    $s.=$str[$k-1];
}

我也知道是循环随机数,但是为啥一次出来的是四个呢
------解决思路----------------------
for 循环里面不是有条件 $i------解决思路----------------------
for($i=0;$i{
    $k=mt_rand(1, strlen($str));
    $s.=$str[$k-1];
}

循环了4次,当然是一次4个了。很正常啊。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn