Skip to content
Advertisement

Keeping array reference and adding something into that

In my very simple Laravel livewire component i have an array and when i try to add another data into that by clicking on a simple for example div i get fresh array with the last inserted data into that and i cant keep this array reference to append something data into that

JavaScript
JavaScript

thanks in advance

Advertisement

Answer

If you’re looking to add a key value pair to an existing array, you most likely want to use array_merge rather than array_push.

array_merge combines two arrays into a single array whereas array_push adds elements to an existing array.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement