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.
gloriaewold41Asked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.