RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.78% (6.81%*) • Investment PI: 5.49% (6.32%*)

Trim Values in an Array or Multidimensional Array

This is a handy reference for trimming values in an associative array. While there's any number of ways to achieve the result, this works nicely.

1
<?php 
2
$results = array_map(array_map('trim', $results));

A multidimensional array is immune to the above code. The following function will work on a string or array.

1
<?php 
2
/*
3
 Trim Values in an Array or Multidimensional Array
4
 http://www.beliefmedia.com/code/php-snippets/trim-array-values
5
*/
6
 
7
function beliefmedia_trim($data) {
8
 if ($data == null) return null;
9
 
10
 if (is_array($data)) {
11
   return array_map('beliefmedia_trim_array', $data);
12
 } else return trim($data);
13
}

Got an easier way? Let us know.

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  E. Australia Standard Time [ UTC+10, Default ] [ CHECK TO CHANGE ]

  Want to have a chat?
 

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment