Reputation: 253
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.
Upvotes: 0
Views: 1290