I have a text file with contents such as following which are ids and names.
23414,apple
24323,orange
64563,banana
In a PHP file I read in the content of the text file into an array like
$itemArray = array();
$records = file('/path/to.file/guilds.txt');
foreach ($records as $line) {
$lineArray = explode(',',$line);
array_push($itemArray,$lineArray);
}
If I know the id of a particular record say 24323, how can I return the associated name, orange. All ids are unique. I tried something like the following with no luck.
$id = 24323;
echo "Result:" . array_search($id, array_column($itemArray,1,0));
Edit: To clarify code.