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
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!!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.