/    Sign up×
Community /Pin to ProfileBookmark

array contents into string

I know I’ve done this before, but I just can’t remember how.

<?php
$address = array();
$address[0]=”123 nearstreet”;
$address[1]=”333 middlestreet”;
$address[2]=”321 farstreet”;
// several addresses

$multi_address = $address[0].” “.$address[1].” “.$address[2];

echo $multi_address;
?>

should output:

123 nearstreet 333 middlestreet 321 farstreet


************************************

What I need is to retrieve several addresses from the “address” table into an array and into $multi_address as a single string.
My attempt:

<?php
$multi_address = “
$j = 0;
while($j < $i){ // $i = number of records
echo $address[$j].”|”. ;
$j++;
}
“;
?>

Of course it does not work, but I’m sure you get what I’m attempting.

My goal is to retrieve several addresses into a string and use that string in a google maps api.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@anothenauthorJan 16.2010 — YAAY!! **dances around**

thx charles, worked perfectly.
×

Success!

Help @anothen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...