I can’t use array_splice since my element is an object. Instead of inserting it as a whole, it inserts it field by field.
P.S.
I was inserting as Leigh said:
array_splice($original, 2, 0, $obj);
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.
If you pass your object directly to
array_spliceyou will get the behaviour you describe.I think you are doing this:
When you should be doing this:
This way your object will be inserted as a whole, instead of the individual fields being inserted.