I am trying to refactor some of my code with arrays
and what I have here is this
$body[] = array(
//array stuff part1 here
);
$body[] = array(
//another array stuff part2 here
);
$body[] = array(
//and another array stuff part3 here
);
now what I want to do is separate them into functions like this
part1();
part2();
part3();
and than assign variable to these functions back to the same stop..do I call it like this
$body[] = part1();
or can I call it like this
$body = part1();
$body = part2();
$body = part3();
if I do it like this will they override each other ?
$body[] = part1();
this syntax append at the end of array$body
.$body = part1();
this is simple assignment so value of$body
variable updated. – jagad89 Apr 27 '16 at 16:59$body = anythign
will overwrite whatever was in$body
withanything
.$body[] = anything
is the equivalent ofarray_push()
, and will append theanything
to the $body array. – Marc B Apr 27 '16 at 17:02