Jump to content

Recommended Posts

Posted

Boas ppl. Tou a tantar criar uma matriz em php, mas não consigo... Tenho o código seguinte:

for($i=1; $i<10; $i++)

for($j=1; $j<10; $j++)

$matriz[$i][$j] = 1;

Isto devia preencher a matriz toda, mas se tentar imprimir algum elemento da matriz fora do ciclo for, não aparace nada, parece k a matriz fica vazia quando sai do ciclo for. Alguém me sabe dizer porquê?

Posted

experimenta assim:

<?

for($i=1; $i<10; $i++){

for($j=1; $j<10; $j++){

$matriz[$i][$j] = 1;

echo $matriz[$i][$j];

}}

echo "<br>"

echo $matriz[1][2];

?>

faltavam os parentesis!!!!

abraço Carlos Aparício

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.