Categories
PHP

Search a multi-dimensional array for a value and return a breadcrumb-like trail using PHP

This one had me stumped!! Working with arrays is something that every developer has to be comfortable with. Fortunately PHP has mountains of array functions to offer. Consider the following data: <?php // here is some test data $categories = array( array( ‘name’=>’Minerals’ ), array( ‘name’=>’Animals’, ‘children’=>array( array(‘name’=>’Mammals’), array( ‘name’=>’Reptiles’, ‘children’=>array( array(‘name’=>’Puffadder’), array(‘name’=>’Cape Cobra’) ) […]