Hi there everyone!
I’ve got an array that looks like this:
Array
(
[0] => Array
(
[id] => 1
[name] => SESX Demo
[safename] => sesx-demo
[ip] => domain.com
[port] => 30120
[dbhost] => 127.0.0.1
[dbname] => c1
[dbuser] => schwim
[dbpass] => pass
[framework] => sesx
)
[1] => Array
(
[id] => 2
[name] => Testing really long server name
[safename] => testing-server
[ip] => 111.111.111.111
[port] => 30120
[dbhost] => localhost
[dbname] => fivem
[dbuser] => root
[dbpass] =>
[framework] => custom
)
[2] => Array
(
[id] => 3
[name] => Scotch & Iron
[safename] => scotch-iron
[ip] => scotchandiron.org
[port] => 30120
[dbhost] => domain.com
[dbname] => general
[dbuser] => user
[dbpass] => pass
[framework] => esx
)
)
And I need to work with just one of the server ID’s at a time To explain better, as an example, I want to get all the vars for ID1 named SESX Demo… I tried to do a while inside the foreach loop to try to do it but that causes an infinite page load:
$server_id = ‘1’, so I had hoped my while would retrieve all the necessary vars while in that part of the loop.
foreach($serverlist AS $server){
while($server['id'] == $server_id){
$server_name = $server['name'];
$server_safename = $server['safename'];
$server_host = $server['host'];
$server_port = $server['port'];
$server_dbhost = $server['dbhost'];
$server_dbname = $server['dbname'];
$server_dbuser = $server['dbuser'];
$server_dbpass = $server['dbpass'];
$server_framework = $server['framework'];
}
}
What’s the best way to handle retrieving the data of only one subset of the array based on the value of one of the subset’s vars?