php - Variable inside recursive function change in for-loop -
I have a variable that is the argument of a recursive function, and its value changes in the warning code without it Resonate in $ idParent
and for
, and the value is different.
Public Function Sort Carburebailleval ($ ranges, $ level max, $ IdParent, $ currentLevel = 0) {$ sorted categories = array (); $ CategoriesFiltered = array (); // Here's what I have not been considered: The echo has been sent for 'idpint fonts:'. $ IdParent; // ID for output ($ i = 0; $ i & lt; Count ($ ranges); $ i ++) {echo '& lt; Br / & gt; "For" idParent: '; Var_dump ($ idParent); // Output -1 No matter what !!!! Echo & lt; Br / & gt; Private Identity: '; Echo isset ($ idParent); $ Level = $ categories [$ i] - & gt; Level; Echo & lt; Br / & gt; RAN & lt; Br / & gt; '; If ($ level == $ current transaction) {echo ' ID] [0] = $ categories [$ i]; Echo & lt; Br / & gt; ENREGISTREMENT & lt; Br / & gt; '; } Else {echo & lt; Br / & gt; SAUVEGARDE & lt; Br / & gt; '; $ Ranges filter [] = $ categories [$ i]; } / * Echo '& lt; Br / & gt; '; Var_dump ($ categoriesFiltered); Echo & lt; Br / & gt; '; * / If ($ currentLevel & lt; $ levelMax) {echo '& lt; Br / & gt; Apple & lt; Br / & gt; '; $ CurrentLevel ++; $ Sorted categories [$ currentLevel] [$ categories [$ i] - & gt; ID] [1] [] = $ this- & gt; Sort Carrefourleval ($ categories filter, $ level max, $ id, $ current level); }}} Return $ Sorted categories; }
The result is:
The fonts are sent to the IDPAR: -1- "IDF" for: Int (-1)
ISPIT ID: 1
RAN
Traffication - ID preceding the condition: -1 ID: 18
EnergyGent
APPEL
Function to IDPRER: 18
IDPear "for": Int (-1)
IDSet: 1
RUIN
I have bold in the part I do not understand Come on.
Comments
Post a Comment