How to apply functions or TRIM Multi Dimensional Arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
carmen.smth1
Forum Newbie
Posts: 8
Joined: Mon Sep 29, 2008 12:45 pm

How to apply functions or TRIM Multi Dimensional Arrays

Post 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>";
?>
User avatar
sergio-pro
Forum Commoner
Posts: 88
Joined: Sat Dec 27, 2008 12:26 pm

Re: How to apply functions or TRIM Multi Dimensional Arrays

Post 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>";
 
 
?>
 
Post Reply