I have some code that has been written in for php 5.3.0 using the USE function within PHP
can someone help me change this to work for 5.2.9?
$available = array_filter($objects, function ($object) use ($week) {
return !in_array($object, $week);
});
thanks for the help
Not nice, but this would be an equivalent implementation.
class MyWeekFilter {
protected $_week;
public function __construct($week) {
$this->_week = $week;
}
public function filter($object) {
return !in_array($object, $this->_week);
}
}
$filter = new MyWeekFilter($week);
$available = array_filter($objects, array($filter, 'filter'));
Is there any difference between author's code
$available = array_filter($objects, function ($object) use ($week) {
return !in_array($object, $week);
});
and
$available = array_diff($objects, $week);
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With