The dateevent field contains values in the Ymd format. When filtering, I try to substitute the $dattw variable with the current date in order to unload all values that are larger than the current date from the array.
The filter does not work and unloads all the values if, instead of $dattw variable, I directly enter the value 2015-11-30 filter safely works, unloading the dates I need. Help where is the error?
<?php $dattw = date("Ymd"); $mykey_values = get_post_custom_values('dateevent'); foreach ( $mykey_values as $key => $value ) $filteredarray = array_filter ($mykey_values, function ($item) { return ($item >$dattw); }); sort ($filteredarray); foreach ($filteredarray as $filteredarray => $value) echo "$value<br>"; ?>