I have an array that looks like this:
Id = "ADA001" Stock: 15
There are about 1700 entries in the array that look the same, how would I look for an array for identifier 1 and return the stock?
Edit: I will need to access the stock of each of these 17,000 records
Edit: I got some help from Daniel Centore, he told me to set the primary arrays key for the item id and that it is equal to the fund, but I canβt get it to work.
I am currently retrieving data from a MySQL database and I am storing it in an array, for example:
$data[] = array(); $getdisposabletest = mysqli_query($connect, "Select id, disposable FROM products"); while ($z = mysqli_fetch_array($getdisposabletest)) { $data = $z; }
Now when I use Daniels code that looks like this:
$myMap = []; foreach($data as $item) { $myMap[$item['id']] = $item['disposable']; }
It does not return anything when I try to repeat my product with the identifier "ADA001"
echo $myMap["ADA001"];
Also, when I do "count ($ mymap)", he says that his 2 entries are big, when he should be bigger than that?
thanks for the help
source share