Jump to content

Archived

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

AncientSage

Name for array element instead of number...

Recommended Posts

Hello,

I'm getting results from a database, and it's doing as I expect, however, if I do something like this...

$row['config_name']['file_size']

...where config_name is the column, and file_size is the row, I cannot access it. Instead, I have to do this:

$row[0]['config_name']

To access it, then, I have a $row[0]['config_value'] column/values, however, I don't want to be fetching a number and guess around with what I have, so I'd like the name in replacement of 0 to be as well, the name of config_name.

So yes, I want to be able to access a part of that array, by the name of a row in in config_name. Thanks.

[i]Sorry if I didn't explain that well, I'll explain it better, if needed.[/i]

Share this post


Link to post
Share on other sites
$config_name0=$row[0]['config_name'];

your have to assign a varable to the name for it to make human sence ok.


Share this post


Link to post
Share on other sites
Meh. So there is no easier way to force it to use names instead of numbers when drawing from a database?

Then I guess I'll have to make sure I do this all very carefully.

Share this post


Link to post
Share on other sites
If you are getting results from a database use mysql_fetch_assoc, this returns an associative array, for example it uses the fields names for the array key rather than a number, rather than mysql_fetch_row.

Share this post


Link to post
Share on other sites

×

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.