echo hello($all);
today i will show you a deliriums peace of code that was written because i was interested in smaller array to pass paramiter like in render, and i think meny other places, so my code create:
from
array(‘month=>5’,‘year’,‘some’=>$value);
array(‘month’=>5,‘year’,‘some=>$value’);
// now mainly i use
array(‘month’,‘year’,‘some=>$value’);
array that fits sending to render or partialRender (current examples will generate:)
array(‘month’=>5,‘year’=>$year,‘some’=>$value);
public function p($iarr){
$arr='array(';
foreach ($iarr as $item => $key)
$arr .= is_numeric($item)?(strpos($key,'=>') === false)?"'$key'=>".'$'."$key," : "'".strstr($key, '=>', true)."'".strstr($key, '=>') .',' : "'".$item."'".'=>'.$key.',';
return $arr.');';
}
Usage
$params = array('month=>5','year','some'=>$value);
eval('$params='.$this->p($params));
$this->render('progress',$params);
not recommended to use complex variable type like Objects,Array,etc in form of
array('bad_example'=>$array_or_Object);
instead use this
array('bad_example=>$array_or_Object'); // is fine;
or
array('array_or_Object'); // will generate array('array_or_Object'=>$array_or_Object);