Parsing With PHP [Part1]
PHP July 28th, 2008
Hehe.. I learn how to parsing with PHP. I read some books and find so many tricks to parsing text using PHP.. So I’ll try one by one^^ First, I tried to simple parsing with PHP. There are some technique for parsing that I learned today.
Parsing Comma-Separated List
How to parsing from comma-separated list then make it to array. First you can using explode() function. Lookout this example.
1 2 3 4 5 6 7 8 9 10 11 12 | <?php // define comma-separated list $menu = "butter, milk, sugar, salt, flour, caramel"; // decompose string into array // using comma as delimiter $menu = explode(", ", $menu); // iterate over array // print individual elements foreach ($menu as $i) { echo $i . "<br />"; } ?> |
| Tags: Parsing, PHP, Tutorial |




About



