Page 1 of 1

How to apply functions or TRIM Multi Dimensional Arrays

Posted: Mon Dec 29, 2008 12:58 pm
by carmen.smth1
Hey again, Yes, It seems I am having another problem with multi dimensional arrays.

Basically, I want to strip html, trim, and rmeove whitespace characters from my Array Array's

Ive tried, array_walk,Array_map, Array_walk_recursive, Plus other self built functions, But I just cant do it.

My array keys arnt numeric.

Heres an example code to work with, Hope some1 here maybe able to solve it.
Thanks

Code: Select all

<?php
$Array = array(array(" RedArrow", "<p>Php)); 
 
print "<PRE>";
print_r($Array);
print "</PRE>";
?>

Re: How to apply functions or TRIM Multi Dimensional Arrays

Posted: Mon Dec 29, 2008 2:07 pm
by sergio-pro

Code: Select all

 
<?php
 
$Array = array(array(" RedArrow", "<p>Php"));
 
print "<PRE>";
print_r($Array);
print "</PRE>";
 
foreach ($Array as $k=>$v) {
    foreach ($v as $kk=>$vv) {
      $Array[$k][$kk] = strip_tags(trim($vv));
    }
}
 
print "<PRE>";
print_r($Array);
print "</PRE>";
 
 
?>