Jump to content

Can't access array elements?


ballhogjoni

Recommended Posts

what am I doing wrong? I have an assoc array, but I can't seem to access it.

$var = Array
(
    'domain' => asdfasdf.com
    'port' => 2082
    'adminuser' => admin
    'INST_password' => adsfasdf
    'adminnickname' => admin
    'adminemail' => [email protected]
    'sitename' => Play Bingo Online Austrailia
    'description' => How to play bingo online in Australia
    'site_root_path' => /home/chris/public_html/
    'theme' => default
    'anchor_one' => How to play bingo online in Australia
    'anchor_two' => play bingo
    'anchor_three' => bingo online
)

if( empty($var['domain']) )
exit;

 

the code exits everytime. What am I missing?

Link to comment
https://forums.phpfreaks.com/topic/234056-cant-access-array-elements/
Share on other sites

im sorry to post back, I forgot about this. I figured it out a while ago. The problem was how I was creating the array. I was using an html form to create the array. So I had something like:

 

<input name="site[0]['domain']" />

<input name="site[1]['domain']" />

etc...

 

So apparently this is wrong, I changed the html inputs to this:

<input name="site[0][domain]" />

<input name="site[1][domain]" />

etc...

 

notice no more single quotes around domain. This change fixed my problem.

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.