Jump to content

[SOLVED] Multidimensional Arrays


Picabrillo

Recommended Posts

Hi,

I can't see what's wrong with this. I've been looking at it for a long time, so maybe a fresh perspective might help.

I created the multi-dimensional array like so:

[code]

<?php

$array = array();

$array['options']['option1'] = array('id');

$array['options']['option2'] = 'name';
$array['options']['option3'] = 'age';
$array['options']['option4'] = 'address';

?>

[/code]

But when later in the script I tested to see if option1 exists with isset($array['options']['option1']) it failed. I checked $array with print_r and it looked like this:

[code]
Array
(
[0] => id
)
Array
(
[options] => Array
  (
  [option2] => name
  [option3] => age
  [option4] => address
  )
)
[/code]

All the other options are fine, I can test them with isset and they come back true. Can anyone give me any idea why option1 isn't a part of the options array even when I stated it?

Thanks in advance people!
Link to comment
https://forums.phpfreaks.com/topic/32869-solved-multidimensional-arrays/
Share on other sites

I feel like such a donut!

I've found the source of the problem. Unfortunately it was completely unrelated to anything I posted, so even the best person wouldn't have worked it out. What I posted was only a segment of a bigger program, but I'd ruled out any possibility that the problem was anywhere else. How wrong I was!!

Sorry about that. The fact it worked for you Sasa made me think it was probably elsewhere, so thank you.

I shall now go and enroll myself back into Primary school!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.