₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,226 members, 8,510,780 topics. Date: Saturday, 31 October 2026 at 04:31 AM

Toggle theme

Help Me Solve This PHP Foreach Function - Webmasters - Nairaland

Nairaland Forum › Science/Technology › Webmasters › Help Me Solve This PHP Foreach Function (667 Views)

1 Reply

Help Me Solve This PHP Foreach Function by internetpo(op): 12:07am On Mar 27, 2013
I queried my database and got the result but I want to add foreach () { echo "," ;} so that it will separate the phone numbers by gotten.

$result = mysql_query($query);

while ($row = mysql_fetch_array($result)) {
echo $row['phone'];
foreach (){
echo "," ;
}
Re: Help Me Solve This PHP Foreach Function by Nobody: 12:58am On Mar 27, 2013
Try dis:

while ($row = mysql_fetch_array($result)) {

$phone_nos = explode (',' , $row['phone']);

foreach ($phone_nos as $phone_no){
echo "$phone_no<br/>" ;
}
}
Re: Help Me Solve This PHP Foreach Function by charliebiz(m): 4:51am On Mar 27, 2013
thanks. what if I want to replace the first character of a string and seperate the array by comma. I was thinking of using ltrim or string replace. Any idea?
1 Reply

Can You Solve This PHP Problem?? • Help To Correct This Php Mailer Code • @Yawa-ti-de:Please Help Me Check This PHP Mailer To See If The Script Is Correct • 2 • 3 • 4

Web Design Contest- Fuoye Offers N100,000 In Total Reward For Foss Site • Blogger Commits Suicide On His 60th Birthday! Pays For Website To Run For The Ne • Helo Guys Pls How Can I Stop A Particular Website From Sending Mails To My Inbox