4

My case is simple: I have an array of texts. I need to use first 2 of them as parameters, and then implode all the rest to a string, to create third parameter. I cannot know how many elements there will be.

  • I don't like copying whole array and deleting $array[0] and $array[1], as it may be a pretty big one and it seems unneeded.

  • I cannot delete values from original array, as I need them for future use.

1 Answer 1

6
foo($array[0], $array[1], join(',', array_slice($array, 2)))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.