[1=>0]+[2=>0] yields [1=>0,2=>0]. But is there any trick to use such syntax sugar for [1]+[2]. So [1]+[2] yeilds [1,2]?
note: My concern is about such syntax, not about other related PHP functions.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is because
+is union operator. It does not append or merge.If you union it’ll become
array(0=>1)as0key already exists in the first array.There is no syntactic sugar to do it. However, you can try this
or in other ugly expression
Also syntactically
[1]+[2] == [1,2]does not make sense at all. Thats python thing.