Created
December 10, 2010 01:43
-
-
Save nickyleach/735630 to your computer and use it in GitHub Desktop.
Simple example of parsing Yelps category structure to dereference an ID
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
<? | |
function find_category($id, $categories){ | |
if(!count($categories)) return false; | |
foreach($categories as $set){ | |
if($set['id'] == $id) return $set['t']; | |
$category = find_category($id, $set['c']); | |
if($category) break; | |
} | |
return $category; | |
} | |
$category = find_category('-Z6XiTi5GStH07pq0NmlZg', json_decode(file_get_contents('http://www.yelp.com/category_tree_json'), true)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment