I have been trying to get this to work and can’t.
I have a string like pop.2,rundo.5,moti.3 and I am trying to get the pop, rundo, and moti into a min with an already populated associative array function.
The final result should look like or mirror,
$min = min($user['pop'], $user['rundo'], $user['moti']);
So far I have
$items = 'pop.2,rundo.5,moti.3';
// EXPLODE MINUS ITEMS
$minus = explode(',', $items);
// GET MINUS ITEMS AMOUNT
foreach($minus as $item) {
$itemMinus[] = explode('.', $item);
}
This is as far as I got and am now stuck. I have tried several ways of doing it but to no avail.
I know I can get the values like so,
$itemMinus[0][0] // pop
$itemMinus[1][0] // rundo
$itemMinus[2][0] // moti
But I need to dynamically generate it as I could be putting in strings that have more values such as youdo.3,gate.3,hiya.4,moti.0,yellow.2.
Any ideas and thanks.
You’re nearly there. Use
list()to get the key and value: