RBA Cash Rate: 4.10% · 1AUD = 0.63 USD · Inflation: 2.4%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.43% (6.02%*) • Home Loan Fixed: 4.99% (5.91%*) • Fixed: 4.99% (5.91%*) • Variable: 5.43% (6.02%*) • Investment IO: 5.59% (6.66%*) • Investment PI: 4.99% (5.91%*)

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 complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

Like this article?

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

Leave a comment