I am using the PDO Api, and using the fetchAll() returns a Multiple Dimensional Array; This snippet below is just a test scenario; I just want to know if it’s possible.
$LeUsername = "BravoSlayer";
$sth = $dbh->prepare("SELECT * FROM users WHERE Username='$LeUsername'");
$sth->execute();
$result = $sth->fetchAll();
print_r($result);
$ArraySearch = search_array($result, $LeUsername);
Output is as below:
Array ( [0] => Array ( [ID] => 1 [0] => 1 [Username] => bravoslayer [1] => bravoslayer [Password] => thisisatest [2] => thisisatest ) )
I want to search through the multi-dimensional array to return the key. IN this case it will be 0 so I can just associate another variable variable for $Array1 = $Array1[‘0’] so from then I can do:
$Username = $Array1['Username'];
Judging by your question. You could search the primary array within a
foreachloop and usein_arrayto return the correct array.Use this as your reference.