Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for Convert JavaScript function to PHP

Current License: CC BY-SA 4.0

8 events
when toggle format what by license comment
Dec 9, 2021 at 9:03 history bounty awarded Community Bot
Dec 3, 2021 at 13:27 history edited Booboo CC BY-SA 4.0
edited body
Dec 3, 2021 at 13:10 comment added Booboo I have re-evaluated the code and updated the answer. My original answer, which was short-sighted, only addressed the issue of modifying the original passed array. But looking at the program logic, I see the need for making this copy. But there is more in my long-winded update, so please read carefully.
Dec 3, 2021 at 13:08 history edited Booboo CC BY-SA 4.0
Added update.
Dec 3, 2021 at 10:47 comment added szmegma Thank you for your response. Do you think in PHP I can skip that JS part? No needed $x=array_merge(array(),$x); If I remove it, the script behaves differently. I updated the question on the top.
Dec 2, 2021 at 16:39 comment added Booboo @ikhvjs Thanks - that's an interesting point! So it's actually a copy-on-write situation. But It is also for all intents and purposes a (possibly release-dependent) implementation detail.
Dec 2, 2021 at 16:02 comment added ikhvjs To be clearer, array in php is passed by reference but it will copy the array when there is a mutation of the array. There is an answer about this. stackoverflow.com/a/9740541/14032355
Dec 2, 2021 at 13:00 history answered Booboo CC BY-SA 4.0

AltStyle によって変換されたページ (->オリジナル) /