Take the 2-minute tour ×

I`ve seen the following notation here: http://www.php.net/manual/en/features.http-auth.php

What is



Is it array and sub array?

Would you please give me a clear example


share|improve this question
$users is an array and $data['username'] is a value from the array $data. The code you posted is retrieving the value of $users with the index value of $data['username']. –  noko Aug 22 '12 at 23:20
add comment

3 Answers

up vote 1 down vote accepted

$data['username'] is just key for assocative array

$data = Array(
  'username' => 'george';
$users = Array(
  'george' => "George Clooney",
  'angelina' => "Angelina Jolie"

echo $users['george']; // George Clooney
echo $users['angelina']; // Angelina Jolie
echo $users[$data['username']]; // George Clooney
echo $data['username']; // george
share|improve this answer
add comment

You should think of it like this:

$username = $data['username'];
$user = $users[$username];

It uses the value from $data['username'] as a key in $users to find a particular user record.

share|improve this answer
add comment

$users is an associate array (see the declaration). $data['username'] is the key used to extract a specific value from that array.

share|improve this answer
add comment

Your Answer


