RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts</strong | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.69% (5.89%*) • Home Loan Fixed: 5.39% (6.59%*) • Fixed: 5.39% (6.59%*) • Variable: 5.69% (5.89%*) • Investment IO: 5.69% (6.48%*) • Investment PI: 5.39% (6.59%*)

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