/    Sign up×
Community /Pin to ProfileBookmark

string splitting???

is it possible to split a string into an array after a specific character e.g. a semicolon…. nd then print/ echo it through a variable e.g….

i have a text file structured like this:

Name;age;area;comment;……. repeated like this.

and i need a php file to show it like this:

name
age
area
comment
continued on like this.

all i need to know is if you can split them after each semi colon and echo it out into the page????

cheers,………JAM

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@aaronbdavisJan 10.2006 — use the explode function. I believe the syntax is [code=php]$arr = explode($string,";")[/code] where $string is your input string.
Copy linkTweet thisAlerts:
@NogDogJan 10.2006 — use the explode function. I believe the syntax is [code=php]$arr = explode($string,";")[/code] where $string is your input string.[/QUOTE]
You've got the parameters reversed: the separator comes first, then the string to be split.
[code=php]
$parts = explode(";", $string);
foreach($parts as $value)
{
echo "<p>$value</p>n";
}
[/code]
Copy linkTweet thisAlerts:
@jamauthorJan 10.2006 — k then i think i get that cheers... JAM
×

Success!

Help @jam 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.19,
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,
)...