Created
May 15, 2013 09:59
-
-
Save ruliarmando/5582896 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function add_b_tags(&$item) | |
{ | |
//$item = "<b>$item</b>"; | |
$item = explode(" ", $item); | |
$r = array(); | |
foreach($item as $i){ | |
$r[] = "<b>".$i."</b>"; | |
} | |
$item = implode(" ", $r); | |
} | |
$arr = array( | |
array( | |
'4'=>'abcd efgh ijkl', | |
'5'=>'mnop qrst uvwx', | |
'6'=>'wawa ghgh dfdr', | |
), | |
array( | |
'14'=>'hfgh fhyj hgjk', | |
'15'=>'nana gfjj fggh', | |
'16'=>'wafd gjgh jhuh', | |
) | |
); | |
array_walk_recursive($arr, 'add_b_tags'); | |
echo "<pre>"; | |
print_r ($arr); | |
echo "</pre>"; | |
$z = array(); | |
foreach($arr as $x => $y) | |
{ | |
$i = 0; | |
foreach($y as $k => $v) | |
{ | |
if($i == 0) | |
{ | |
$z[$x][$k] = $v; | |
} | |
else | |
{ | |
$r = explode(' ',$v); | |
$z[$x][$k] = end($r); | |
} | |
$i++; | |
} | |
} | |
echo "<pre>"; | |
print_r ($z); | |
echo "</pre>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment