I have a name value pair in a settings.ini:
[Server1]
ServerName=Joe
ServerIP=1.1.1.1
ServerPort=1111
[Server2]
ServerName=Schmoe
ServerIP=2.2.2.2
ServerPort=2222
I have read it in using the nifty ini parser.
I have a while loop to cycle through each but I can't get it to assign the variable variable:
while($checkeachserver < server_count)
{
$servernumber = 'Server'.$checkeachserver;
$serverip = $ini_array.$servernumber[ServerIP];
$serverport = $ini_array.${$servernumber}[ServerPort];
print_r($serverip);
$checkeachserver++
}
Both of these return "Array"
Help?
Completely refactored as follows:
foreach($server_array as $item) {
$serverip = $item['ServerIP'];
$serverport = $item['ServerPort'];
$servername = $item['ServerName']; }