• 13-02-2015, 11:27:23
    #10
    Reveloper
    Misafir adlı üyeden alıntı: mesajı görüntüle
    array_unshift fonksiyonunda ilk değerin array olması gerekiyor,
    $vars["registrarcustombuttons"] bir dizi değil, o yüzden aşağıdaki en üst satırdaki eklemeyi yapar mısınız?

    $vars=array("registrarcustombuttons"=>array());
    $dizi=array("label"=>"asd","command"=>"bb");
    array_unshift($vars["registrarcustombuttons"], $dizi);
    print_r($vars["registrarcustombuttons"]);
    denedim hocam yemiyo kod
  • 13-02-2015, 11:30:56
    #11
    Burti adlı üyeden alıntı: mesajı görüntüle
    denedim hocam yemiyo kod
    direk $vars=array("registrarcustombuttons"=>array()); bu şekilde tanımlamak yerine $vars dizisini nerede tanımladıysanız orada registrarcustombuttons kolonuna değer atadığınız yerde yaparsanız olacaktır / olması gerekir.

    Tüm kodlar bunlardan ibaret mi? Özelden atabilir misiniz?

    PHP bir hata mesajı veriyor mu?
  • 13-02-2015, 14:42:04
    #12
    Üyeliği durduruldu
    <?php if ($this->_tpl_vars['registrarcustombuttons']): ?>
       <li class="divider"></li>
       <?php $_from = $this->_tpl_vars['registrarcustombuttons']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
        foreach ($_from as $this->_tpl_vars['label'] => $this->_tpl_vars['command']):
       ?>
       <li><a href="clientarea.php?action=domaindetails&amp;id=<?php echo $this->_tpl_vars['domainid']; ?>&amp;modop=custom&amp;a=<?php echo $this->_tpl_vars['command']; ?>"><?php echo $this->_tpl_vars['label']; ?></a></li>
    <?php endforeach; endif; unset($_from); ?><?php endif; ?>
    
    <?php
    //$registrarcustombuttons=array_unshift($vars["registrarcustombuttons"], array("label"=>"asd","command"=>"bb"));
    array_push($vars["registrarcustombuttons"],array("label"=>"asd","command"=>"bb"));
    print_r($vars['registrarcustombuttons']);
    /*
    printv_r(
    array(1) => registrarcustombuttons
    array(2) => "label" => "as", "command" => "bb"
    );
    */
    foreach($vars['registrarcustombuttons'] as $is):
    echo $is['label'].' - '.$is['command'];
    endforeach;
    ?>
  • 13-02-2015, 17:37:03
    #13
    tolgatasci adlı üyeden alıntı: mesajı görüntüle
    <?php if ($this->_tpl_vars['registrarcustombuttons']): ?>
       <li class="divider"></li>
       <?php $_from = $this->_tpl_vars['registrarcustombuttons']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
        foreach ($_from as $this->_tpl_vars['label'] => $this->_tpl_vars['command']):
       ?>
       <li><a href="clientarea.php?action=domaindetails&amp;id=<?php echo $this->_tpl_vars['domainid']; ?>&amp;modop=custom&amp;a=<?php echo $this->_tpl_vars['command']; ?>"><?php echo $this->_tpl_vars['label']; ?></a></li>
    <?php endforeach; endif; unset($_from); ?><?php endif; ?>
    
    <?php
    //$registrarcustombuttons=array_unshift($vars["registrarcustombuttons"], array("label"=>"asd","command"=>"bb"));
    array_push($vars["registrarcustombuttons"],array("label"=>"asd","command"=>"bb"));
    print_r($vars['registrarcustombuttons']);
    /*
    printv_r(
    array(1) => registrarcustombuttons
    array(2) => "label" => "as", "command" => "bb"
    );
    */
    foreach($vars['registrarcustombuttons'] as $is):
    echo $is['label'].' - '.$is['command'];
    endforeach;
    ?>
    array_push ile array_unshift arasındaki tek fark birinin sona birinin başa eklemesi.