php - array_combine stuck when there is no value in first array -
I am using array_combine ()
, but this error displays when the first time There is no value in it. First Array distance_are array ([0] = & gt;) School_ID_air array ([0] = & Gt;) and $ coverage using $ array Array = array_combine ($ School_ID_Array, $ Distance_Array); The coverage_array array ([] = & gt;) I think in the first array, if a value is empty, coverage_orize key accepts any default key
If you use these conditions: {class = "post-text "Itemprop =" text "// Some codes using $ some_var_or_array value (s)}
UDATED
here The function is ArrayCombine (), which receives three parameters: two arrays and third - Default parameter value will be set to the array values before the empty or nulled:
function ArrayCombine ($ array1, $ array2, $ default = 0) {foreach ($ array1 $ key = & Gt; $ value) {if (! Isset ($ value) || Empty ($ value) {$ array1 [$ key] = $ default; }} Return array_combin ($ array1, $ array2); }
Here the example:
$ Distance_Array = array (1 = "gt;";); $ School_ID_Array = array (3 = & gt; 4,); $ Coverage_are = arrecombin ($ distance_are, $ School_ID_Array); Var_dump ($ Coverage_Array); / * Var_dump Output: Array (1) {[24] = & gt; Int (4)} * /
Comments
Post a Comment