yii - lost var in php -
i new php , yii, , problem not nor question in google, thing can think of inquire question list have solved many problems.
the issue follows: in code attached, read several records maintain in array , after process.
well, if @ debug entries in foreach in first, goes , variable $items
loaded, when sec debug $items
variable has right number of elements, elements empty : count ($items) = 2
$items[0]
, $items[1]
null
$idiomas=clistamidiomas::model()->findall(); $items=array(); $nombre=array(); $a=0; foreach ($idiomas $idioma){ $nombre[$a]=$idioma->sidioma; $items[$a]=tblcategoriastexto::model()->findall( array('condition'=>'id='.$data->id.' , ididioma='.$idioma->id_idioma)); echo "<br>---aaaaaaaaaaa--".$a."-----------<br>"; cvardumper::dump($items); //in moment right if (empty($items[$a]) ||$items[$a]==null ){ // not come in because $items have content $items[$a]=new tblcategoriastexto(); $items[$a]->ididioma=$idioma->id_idioma; } $a++; } echo ">>>>>>>>>>>>>>>".count($items) ; //<<<<<<<<<<present 2 cvardumper::dump($items); // in moment t0 2 null ($a=0;$a<count($items) ;$a++){ echo "<b>".chtml::encode($nombre[$a]).":</b>"; $out=""; $item=$items[$a]; echo "<br>-----".$a."-----------<br>"; cvardumper::dump($items[$a]);<<<<<<<<<<<<<<<<<<<<<<<<null ($b=1;$b<=20;$b++){ $campo="tc".$b; $out.=$items[$a]->$campo . ",";<<<<<<<<<<<<<<<<error } echo chtml::encode($out); echo"<br>"; }
this line: if (empty($items[$a]) ||$items[$a]=null ){
assign $items[$a]
null
.
to compare values, utilize comparing (for equality) operator, ==
instead of assignment operator =
.
php yii
No comments:
Post a Comment