advanced unset the value form array PHP -
I have two arrays that include the array, I need to recursively merge these arrays but I want to The action needs to be done sometime, and
will be created twice by my data, array_merge_recursive ()
I want to delete the element Already exists Target array $ message array:
array (2) {["message"] = & gt; String (23) "The Testonic"} ["Valletars"] = & (2) {{test.testik "] => string (13)" Це тест "[" test2313.tes31231tik "] = String (27) "Zimber Thoribis" ["LegalKinvindica"]; [4] "[4]" [4] Valid {= "Valid."} = & Gt; String (36) "This Vell Vision" ["joga.jimbo"] = ] = & Gt; String (23) "every invoked" ["smith.john"] => string (17) "diagnosis smith"}} $ allCar array: < / P>
array (2) {["message"] = & gt; array (1) {[test2313.tes31231tik "] => String (23) "The Testonic"} ["Valletts"] = & gt; Array (2) {["validka.invalidka"] = & gt; String (23) "Every Invalled" ["smith.john"] = & gt; I have written some code: foreach ($ message = $ message => $ messagesArray) {string} {/ code> foreign currency ($ allCat $ d => ; $ Mess) {if ($ domain == $ d) {foreach ($ messagesArray as $ ymlkey = & gt; $ trans) {foreach ($ ymlk = & gt; $ translate as mess) {if ($ ymlkey = = $ Ymlk) {without set ($ glitch [$ ymlk]); }}}}}}
Then when I run recursive merge, it adds the same value to the array. What am i doing wrong
this:
foreach ($$ C => All cats in the form of $ perturbation) { $ False is a temporary copy that your foreach () loop is currently working when you have your Unset ($ mess ...) later, you are just setting that temporary copy.
While some are indicating $ mess a reference, this can cause problems later, because there will be no reference to $ disturbances even after the loop end , And later, after any re-use of the variable, the disturbances that were now indicated in the previous loop. / P>
Instead, use the full array / object path reference in the unset call:
unset ($ messages [$ domain] [$ d] [$ ymlkey] [$ Ymkl]]
or whatever it may be. In this way you guarantee that you are working with the actual "real" array, and many floating copies of nested ends are not being created by you.
Comments
Post a Comment