• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

str_replace

Hi experts,

I need to split a line wich is in fact two words separated by comma and then identify the output as two words:

word1,word2

result:

$word1 = "word1";
$word2 = "word2";

Please help.
0
gloriaewold41
Asked:
gloriaewold41
1 Solution
 
käµfm³d 👽Commented:
Why not use explode?

e.g.

$result = explode(',', $input);

$word1 = $result[0];
$word2 = $result[1];

Open in new window

0
 
p_nutsCommented:
Use explode()

$line = 'blabla,whatever;
$words = explode(',',$line);

Echo $words[0];
Echo $words[1];

or
Print_r($words);
0
 
gloriaewold41Author Commented:
Thanks. Exactly what i needed.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now