0
Php code defects
Hey SoloLearners i have problem in php can you tell me whats wrong <?php $coords = array; $coords[0] = "-600"; $coords[1] = "56"; $coords[2] = "200"; echo 'go the mc server <redacted>'; echo 'then go to the coords'; echo '$coords[0] $coords[1] $coords[2]' ?>
2 Answers
+ 2
You need parentheses behind array, a semicolon in the last line and print all each value with a single value or concatenate it with dots
<?php
$coords = array();
$coords[0] = "-600";
$coords[1] = "56";
$coords[2] = "200";
echo 'go the mc server thefaceofanarchy.aternos.me:60392';
echo 'then go to the coords' ;
echo ''.$coords[0].' '.$coords[1] .' '.$coords[2];
?>
+ 3
If you already know the elements' values then you can initialize the array as you declare it
$coords = array("-600", "56", "200");
If you use double quote you can have the elements' values be printed as a single line, without concatenation operator.
echo "$coords[0] $coords[1] $coords[2]";
For future reference, explain the situation rather than directly asking what's wrong without any given clue of what your problem be. And it seems you had put something that is against the rule.
P.S. I noticed your Description was edited, FYI, moderators don't do that without a valid reason to, so I advise you to rephrase your Description : )