Jump to content


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


question about arrays

Recommended Posts

What im trying to do here is pull information from a MySQL database. And put all the data into an array. Basicly. Im pulling the collum names from an external file and i am reading it in the php script. As it reads each line and will grab the data from the collum which is named the same. So. If i opened up XYZ.txt and was reading it. And the first line said Servers. It would goto the Table and pull the info from the 'Servers' collum. I was wondering if this syntax will work. Havent had a change to try it out yet. And wont be able to for a little bit.

$x will be the collum name of the current Table .. and $rs is obviously the data from the record set.

$UserData = Array ($x => $rs)

so if i put in echo $UserData[Servers] .. i would need it to print out the data from that collum in the DB. which would be already stored in that VAR. so output for example would be

Does the array have to be constant? I know some languages you have pre defined. and you are unable to just set it as something throughout the application. like.. in VB .. you have to say UserData(0 to 100). Is this the same case for PHP? or will the above piece of code work? If this code does not work. Does anyone have any suggestions on how to do something similar

Thanks in advance for the help!!!

Share this post

Link to post
Share on other sites
Arrays in PHP are dynamic.

You can write this:
[code]<?php $UserData = Array ($x => $rs); ?>[/code]
[code]<?php $UserData[$x] = $rs; ?>[/code]

Read [a href=\"http://www.php.net/array\" target=\"_blank\"]this section[/a] in the fine manual for more information.


Share this post

Link to post
Share on other sites

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