$els = array(
array('id'=> 1,'chance' => 10),
array('id'=> 2,'chance' => 15),
array('id'=> 3,'chance' => 1),
array('id'=> 4,'chance' => 20),
array('id'=> 5,'chance' => 50),
);
function getItem($data) {
$randArray = array();
foreach ($data as $value) {
for ($i = 0; $i < $value['chance']; $i++) {
$randArray[] = $value['id'];
}
}
return $randArray[mt_rand(0, count($randArray) - 1)];
}
.key-svg {
width: 40px;
height: 40px;
padding: 0;
box-sizing: border-box;
border-radius: 1000px;
}
.item {
display: flex;
flex-direction: column;
}
.item .description {
flex: 1;
}
$data = array(
'Lorem',
array(
'Lorem',
'ipsum',
'dolor',
),
'sit',
'amet',
array(
'consectetur',
'adipisicing',
'elit',
'Lorem',
),
);
function removeItems($data, $search) {
foreach ($data as $key => $value) {
if ( is_array($value) ) {
$data[$key] = removeItems($value, $search);
} else {
if (strpos($value, $search) !== false) {
unset($data[$key]);
}
}
}
return $data;
}
print_r(removeItems($data, 'Lorem'));