I'm a big fan of 1tbs when it comes to c-like languages. Now that php got decent lambdas and closures, though, I'm not sure the style I'm using for them (fundamentally made up, has something to do with the jquery source code) is the most readable/standard option. What do you think? Somebody has some nice examples of 1tbs + lambdas and functions as parameters?
Here's a sample of my code.
function bold_search_terms($needle, $haystack) {
return str_replace(
$occurrencies = array_filter (
explode(" ",$haystack),
function ($var) use ($needle) {
return(levenshtein($var, $needle) < 3);
}
),
array_map(
function ($var) {
return "<strong>$var</strong>";
},
$occurrencies
),
$haystack
);
}