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

下面这段如何理解

WBOY
Release: 2016-06-13 12:09:59
Original
887 people have browsed it

下面这段怎么理解
$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个了。很正常啊。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template