-1

I could not find the syntax anywhere in the manual .. Why this syntax works and is there a link to the manual to show this is a correct naming for a variable.

$who = array("World", "universe");

echo "${who[0]}"; //i cant find this syntax 
echo "$who[0]"; //works
echo "{$who[0]}" ; //works
//echo "${who}[0]"; //cant call because this treats an array as a string
//echo "${who}[0]";//cant call because this treats an array as a string
user9718914
  • 103
  • 9

1 Answers1

-1

Simpler:

<?php
$who = array("World", "universe");
echo $who[0];

The man page: http://php.net/manual/en/language.types.array.php

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive. Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

From: http://php.net/manual/en/language.variables.basics.php

Progrock
  • 7,373
  • 1
  • 19
  • 25