I'm working on arrays using php and I am trying to swap items of the array. I have this code:
<html>
<body>
<p>
<?php
$test2 = array ( array("!","#","#"),
array("@","!","#"),
array("@","@","!",)
);
for($f=0; $f < count($test2); $f++)
{
for($g=0; $g < count($test2); $g++)
{
if($g >= 2)
{
echo "{$test2[$f][$g] } ";
}
else
{
echo "{$test2[$f][$g] }- ";
}
}
echo "<br>";
}
...
the code above has an output of:
!- #- #
@- !- #
@- @- !
I am trying to swap the index of the arrays so the output will be like this:
!- @- @
#- !- @
#- #- !
Thank you guys for the help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.