Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
110 views
in Technique[技术] by (71.8m points)

How to concatenation php array separated with comma

$data=['test','test2'];

I try with

$finalData = implode(',',$data);

Actual result

var_dump($finalData);
output : string(10) "test,test2"

Accepted result

var_dump('test1','test2');
output:  string(5) "test1" string(5) "test2"

Thanks in advance

question from:https://stackoverflow.com/questions/66046060/how-to-concatenation-php-array-separated-with-comma

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you need push array values in function as separated arguments, you are probably searching for Argument unpacking

This can be done by ... operator.

Used as

functionCall(...$array);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...