1

What will be the fastest and best way to convert the following PHP associate array to a string without json.

array

 Array ( [0] => A [1] => S [2] => G) 

to a string, exactly like

String =  "A, S, G";

Most of the solutions available are using JSON, that I don't want to use. plus I want to know the "Fastest" and "Best" way.

2
  • @Rizier123 Most of those solutions are json, that I can't use. plus, I want to know the 'Fastest' and best way. Commented Jan 25, 2017 at 18:47
  • 1
    Why not consider the accepted answer to that duplicate question? What makes you believe that it isn't the fastest and best way? Commented Jan 25, 2017 at 19:46

3 Answers 3

3

Use the implode function:

$str = implode(array('a', 'b', 'c'));

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

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

Comments

0

Use implode()

And read more here http://php.net/manual/en/function.implode.php

Comments

-1

One way is using print_r(array, true) and it will return string representation of array

1 Comment

Sure, but this will not produce the result the OP specifically asks for.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.