PHP comma separated string to list
PHP comma separated string to list
This script will show you how to separate a string that contains comma, semicolon etc and then list it accordingly. Here we are using explode() and also empty(). If there is an empty space between two comma or semicolon then that is automatically discarded. Here is how the code looks.
$country = "USA, canada, brazil, india, ,australia, malaysia, singapore"; $arrCountry = explode(",",$country); foreach($arrCountry as $v){ $d=trim($v); if(!empty($d)) { echo $d."<br />"; } }
Here i have purposefully given an empty area between INDIA and AUSTRALIA and that is discarded during the execution.Here is how the O/P looks
USA
canada
brazil
india
australia
malaysia
singapore
Incoming search terms:
- tellafriend php (6)
- taf php (5)
- email-to-friend php (4)
- /tell-a-friend php?subject (3)
- /tellafriend php (3)
- com/EmailFriend php (2)
- EmailToFriend html (2)
- email friend subject (2)
- net/index php?tell_a_friend_en&taf= (2)
- emailtofriend php (2)
- tell a friend with subject (2)
- email listing to a friend (1)
- Email Listing To Friend php? (1)
- Email Page to a Friend (1)
- email friend php listing id 380 (1)
- xbotsforum org/send page_email a friend php (1)
- Email This listing to a Friend (1)
- Email This Listing to a Friend Email This Listing to a Friend (1)
- email to a friend (1)
- email-a-friend/index php?page=invite (1)
- email-friend with subject (1)
- emailfriend php?id= (1)
- emailfriend_listing (1)
- email friend Listing php (1)
- Email Email this page emailtofriend php (1)
- email a listing to a friend69 (1)
- /tell-a-friend subject (1)
- /_email_a_friend php?ai=id (1)
- au/Tell/tell php=email_listingview (1)
- california tell a friend with subject (1)
- canada tell a friend with subject (1)
- clementsandmccarthy net/index php?action=contact_friend&popup=yes&listing_id= (1)
- com au/enviar to a friend=listing php_id (1)
- com/email_friend php?mls (1)
- com/list?q=email_to_friend/friend php (1)
- com/tellafriend2 php (1)
- danielaemail this page to friends separate with commas with subject (1)
- E-MAIL-THIS-PAGE-TO-A-FRIEND/subject= (1)
- email a friend listing (1)
- email a friend/apsx/php (1)