1

Please help me to convert a string into single dimension array...

example

$str = abc,xyz,pqr;

convert to

$arr = array('abc','xyz','pqr');
1
  • can anyone help me to convert this...??? Commented Nov 14, 2013 at 8:00

2 Answers 2

3

Try with explode like

$str = 'abc,xyz,pqr';
$str_arr = explode(',',$str);
print_r($str_arr);

Try this EXPLODE

Sign up to request clarification or add additional context in comments.

Comments

1

use php function

explode(',',$str);

2 Comments

hi gautam i know explode function it gives output as array( 0 =>'abc', 1 => 'xyz', 2 => 'pqr'). this is not i want I want this array('abc','xyz','pqr')
that's how you instantiate your array and by default an array should have keys

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.