Q:

Looping and conditional in array php

i want to make loopng and condtional in array to make schedule calendar from

$this->widget('ext.yiicalendar.YiiCalendar', array
(
    'linksArray'=>array
     (    
        '2014-12-13'=>array
        (
           'title'=>'hahaha! :]',
            'style'=>'font-weight: bold; color: red;',
            'href'=>'#'
         )
      )
  ));

to
$this->widget('ext.yiicalendar.YiiCalendar', array
(
'linksArray'=>array
(
  $a = 0;
  while($a < 10)
  {
    if($a != 0)
    {
    '2014-12-13'=>array
    (
        'title'=>'hahaha! :]',
        'style'=>'font-weight: bold; color: red;',
        'href'=>'#'
    )
    }
   $a=$a+1;
  }
 )
 ));

But it doesn't work, please i need your help :(

A:

Just create new variable to cache it before you pass it to array
$my_schedule=[];
$a = 0;
while($a < 10) {
  if($a != 0){
     $my_schedule[] = [
      'title'=>'hahaha! :]',
      'style'=>'font-weight: bold; color: red;',
      'href'=>'#'
     ];
   }
   $a++;
}

$this->widget('ext.yiicalendar.YiiCalendar', array('linksArray'=> $my_schedule);

I don't totally understand what you wanna. But if you want loop inside array, you could try my way. So glad to help you, ubay

