Answer the question
In order to leave comments, you need to log in
How to see if the passed numeric value of the variable lies between the values of the array?
The essence of the task is as follows:
The site has a slider that adjusts the price range and transmits 2 values, for example - "price from=1000" and "price to=2000",
in turn, these values are elements, for example, of such an array:
$filters = [
'Categories (xyz..)' => 'Обувь,Свадебная обувь по 1-ой паре',
'Color' => ['белый', 'бежевый'],
'Size' => '35',
'Manufacturer' => 'кожзам',
'Wholesale price' => [1000, 2000],
];
array (size=22)
'A072C02' =>
array (size=2)
1 =>
array (size=67)
'ID' => string 'A072C02' (length=7)
'Wholesale price' => float 1404
'Color' => string 'белый' (length=10)
'Size' => float 35
'' => null
2 =>
array (size=67)
'ID' => string 'A072C02' (length=7)
'Wholesale price' => float 2100
'Color' => string 'белый' (length=10)
'Size' => float 36 '' => null
Answer the question
In order to leave comments, you need to log in
$range = [1000, 2000];
foreach($items as $key => $item) {
$price = $item['price'];
if ($price < $range[0] || $price > $range[1]) {
unset($items[$key]);
}
}
But if this array is selected from the base, then it's probably better to set it in the request.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question