显示循环随机和交叉的两个循环

i have looping problem, i want To show replay random To looping

Code:

            for ($i=0; $i <= 10; $i++) { 
            $result = $i;
            echo "$result";
            echo "<br>";
            }
    //----------------------------------------------
            echo "<hr width='100%'>";
    //----------------------------------------------
            $s=$result;
            $c=$result;
            $test=array_fill($s, $c, 0);
            $ts=microtime(true);

            for ($i=0; $i <= 10; $i++) { 
                $selection1=mt_rand($s, $c);
                $selection2=mt_rand($s, $c);

                echo "$selection1 and $selection1";
                echo "<br>";
            }

i want result: example result

and after random i want cross looping Example result

#including completion of a genetic algorithm  
</div>

mt_rand returns a value between the first and last values you provide. In your code, you are calling mt_rand($s, $c) when $s and $c are both set to 10, so they will always return 10.

I'm having trouble understanding what you want, so let's take a look at your code and see what's going on.

        for ($i=0; $i <= 10; $i++) { 
            $result = $i;
            echo "$result";
            echo "<br>";
        }

Above we're looping between 0 and 10, each time around storing our loop number as $result.

//----------------------------------------------
        echo "<hr width='100%'>";
//----------------------------------------------
        $s=$result;
        $c=$result;
        $test=array_fill($s, $c, 0);
        $ts=microtime(true);

Our loop has finished and we're moving on. This code is executed once. Since $result was 10 at the end of the loop, $s and $c will always be set to 10.

        for ($i=0; $i <= 10; $i++) { 
            $selection1=mt_rand($s, $c);
            $selection2=mt_rand($s, $c);

            echo "$selection1 and $selection1";
            echo "<br>";
        }

We're now going to loop between 0 and 10 again. mt_rand() will always return a value between $s and $c, which will always be set to 10 and 10, so will always be 10. We're just going to echo 10 and 10 10 times.

I'm unsure what you're looking for so I'll just leave that explanation there.