Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 10-26-2006, 02:57 PM   #1 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default php multidimension array

PHP Code:
<?

$arr 
= array(

"One" => array("One" => "1,1""Two" => "1,2"),

"Two" => array("One" => "2,1""Two" => "2,2")

);

echo 
$arr["One"]["Two"]."
"
.$arr["Two"]["Two"]."
"
;

echo 
$arr[0][1]."
"
.$arr[1][1]; //line 13
?>
produces

Code:
1,2
2,2

Notice: Undefined offset: 0 in c:\Inetpub\wwwroot\array.php on line 13

Notice: Undefined offset: 1 in c:\Inetpub\wwwroot\array.php on line 13
why cant i use indices to reference elements in the array?
office politics is offline  
Old 10-27-2006, 10:02 AM   #2 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default

PHP Code:
<?

$arr 
= array(

"One" => array("One" => "1,1""Two" => "1,2"),

"Two" => array("One" => "2,1""Two" => "2,2")

);

$arr2 = array(

array(
"1,1","1,2"),

array(
"2,1","2,2")

);

echo 
$arr["One"]["Two"]."
"
.$arr["Two"]["Two"]."
"
;

echo 
$arr2[0][0]."
"
.$arr2[1][1];
?>
produces

Code:
1,2
2,2
1,1
2,2

office politics is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On