/** throw this in your child theme's "functions.php" file
* Encode an email address to display on your website
* converts the address to ASCII character codes
* that the browser displays fine but most spambots can't decipher.
* usage: [encode_email email="you@yourdomain.com"]
function encode_email_address( $atts ) {
	$atts = shortcode_atts(
			'email' => false,
		), $atts, 'encode_email');
	if(!$email) return;
	$output = '';
	for ($i = 0; $i < strlen($email); $i++) {
		$output .= '&#'.ord($email[$i]).';'; 
	return $output;

Easy peasy:

$newArray = array_filter($array);

What if they aren't truly empty, but contain blanks, you ask?

$trimmedArray = array_map('trim', $array);
$newArray = array_filter($trimmedArray);

Remember array_map? That handy-dandy function that lets process every element of an array using a function?

It's so simple, yet I always forget this one and need reminding:

$result = array_map('trim', $source_array);

Array_map has many other potential uses as well ...

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

Email sending image

You have Successfully Subscribed!