| Autor | Zpráva | ||
|---|---|---|---|
| Čamo Profil * |
#1 · Zasláno: 4. 9. 2015, 23:59:43
Zdravím,
prosím vás, našiel som vo form helpery z Codeignitera 3 takýto kód a neviem načo je tam ten foreach, keď je za ním array_merge. Nerobí náhodou to isté ako ten array_merge? function _parse_form_attributes($attributes, $default)
{
if (is_array($attributes))
{
foreach ($default as $key => $val)
{
if (isset($attributes[$key]))
{
$default[$key] = $attributes[$key];
unset($attributes[$key]);
}
}
if (count($attributes) > 0)
{
$default = array_merge($default, $attributes);
}
}
... |
||
| tiso Profil |
#2 · Zasláno: 5. 9. 2015, 00:35:01
Nie, nerobí. Ale celý kód by sa dal prepísať ako:
function _parse_form_attributes($attributes, $default)
{
if (is_array($attributes))
{
$default = $attributes + $default
}
... |
||
| Camo Profil |
tiso:
Ak sa ale číselné indexi nepoužívaju tak je to zbytočné, nie? |
||
|
Časová prodleva: 10 let
|
|||
0