This is a recursive PHP function that searches all of the keys in an array and pulls out their values.
<pre id="geshi_code">function multi_array_key_search($needle,$haystack,$keys_found=array()){
if(is_array($haystack)){
foreach($haystack as $key=>$val){
if(is_array($val)){
$keys_found = multi_array_key_search($needle,$val,$keys_found);
}else{
if($key==$needle){
$keys_found[] = $val;
}
}
}
return $keys_found;
}
return false;
}
February 15th, 2008
/ Tags: code, php / Trackback
I just wrote some pretty quick code for the age-old problem of alternating colors in a table. I don’t know how this could get any simpler. Sweet!
<pre id="geshi_code"><? foreach($posts as $post){?>
<div class="<?=($c++%2==1)?'odd':NULL?>">
<?=$post?>
</div>
<? }?>
<style>
.odd{background-color:red;}
</style>
February 15th, 2008
/ Tags: code, php / Trackback
For every 4 floated elements, wrap to the next line:
<?=($b++%4==0)?’<br class="clr" />’:NULL?>
February 15th, 2008
/ Tags: code, php / Trackback
I started using a new coding framework called Cake. It’s a style of coding based on Ruby on Rails using the “Model, View, Controller” pattern. Cake is meant to speed up the development time of web projects. I’ll try to keep this site updated on my progress. I’d ideally like to recode this website using cake once I become more familiar. Right now I’m using the code at work to create a backend website administration app.
April 29th, 2005
/ Tags: code / Trackback