Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,569 members, 7,809,080 topics. Date: Thursday, 25 April 2024 at 10:32 PM

Help Me Solve This PHP Foreach Function - Webmasters - Nairaland

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

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)

(1) (Reply)

Help Me Solve This PHP Foreach Function by internetpo(m): 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)

Either Do It The Easy Way Or Die Trying Seo Services For Marketing / Urgently Needed / C# Csv Parser

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 5
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.