I am using Yii, and I want to print an index of an array, but I get an error that the index is undefined, here is my code:
$criteria = new CDbCriteria;
$criteria->select = 'username, password'; // select fields which you want in output
$u = Users::model()->findAll($criteria);
foreach($u as $u)
$users["$u->username"] = "$u->password";
echo $users['a'];
I printed the array and make sure that a index is exist, so what is the problem here?
var_dumpyour array and see what indexes are there. Also($u as $u)is BAAAD idea.awas stored in the the db with w space so it is ` a`, I think I need to visit the ophthalmologist.trim()to just clean it up here...