Autor Zpráva
Čamo
Profil *
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
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
  }
...
viď Sjednocování polí
Camo
Profil
tiso:
Ak sa ale číselné indexi nepoužívaju tak je to zbytočné, nie?

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0