Home php Adding an element in an array (array_push)

Adding an element in an array (array_push)

Author

Date

Category

What am I doing wrong, why does not array return?


Answer 1, Authority 100%

Return in both cases the variable $ Exploded , since the array_push function changes the array specified in its parameters and returns the number of items after adding new.

Described in detail here http://php.net/manual/ru/function .Array-Push.php


Answer 2, Authority 50%

Array_Push does not work like this.

Link to the documentation

The first parameter you specify an array, in which elements transmitted by the second and then arguments will be inserted.

In your case, you need to do this:

if (! empty ($ DATA)) {
  Array_Push ($ Exploded, $ DATA);
  Return $ Exploded;
} ELSE ....

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions