How to remove empty values from an array

We frequently need to remove empty values from an array in PHP. I think doing it by function array_filter is a good idea.


$a = array( 1, 5, 0, 'c', '', 'php', ' ', 'html', 189 );

$b = array_filter( $a, 'my_empty' );
function my_empty( $var ) {
 $var = trim( $var );
 if ( '' == $var ) {
 return false;
 return true;

print_r( $b );

It can remove all empty string and extra white space values, but keeps the zero number.

Make buttons have pressed effect

Here I will introduce the small trick. You only add a little code, then make buttons have pressed effect. Just like a button is really pressed. See the codes below.

See the Pen Pressed Button by wpaesthetic (@wpaesthetic) on CodePen.18474

Just doing two things:

  1. Set the position property of the button tag with relative value.
  2. Set the top property with 1px value.