0

I have multi string with the names:

$string[0], $string[1], ..., $string[$i]

I want to convert them to one array like:

array($string[0], $string[1], ..., $string[$i])

For example, if there are 4 strings, the array is:

array($string[0], $string[1], $string[2], $string[3])
3
  • 1
    In what language? php? Please add an appropriate tag to your question. Commented Mar 2, 2013 at 13:17
  • 3
    ehm... isn't your variable $string the result you want? Commented Mar 2, 2013 at 14:10
  • $arrayOfStrings = array($string[0], $string[1], $string[2], $string[3]); ?? Commented Mar 2, 2013 at 15:01

2 Answers 2

1

array($string[0], $string[1], $string[2], $string[3])

Doing this is exactly doing nothing. $sting is itself an array having values $string[0], $string[1],.....$string[$i]

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

1 Comment

Oh, so that's how it is. Sorry for being an "amateur". Thanks for showing me this.
0

Say if ur input is:

      $input = "test1, test2, test3, test4";

You could do,

      $to_array = implode(",", $input);

http://php.net/manual/en/function.implode.php

Is this what you're looking for?

1 Comment

No. For example, we have a textarea tag to input text. Then the info will be converted by some function, eventually resulting in these separated strings through loop: $string[0], $string[1], ..., $string[$i]

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.