adde
(Andreas Furst)
October 25, 2012, 6:02pm
1
Hi,
Im using ClistData to create an array from a database table, the problem is that I want to wrap the textfield within a function(mb_convert_encoding) to encode the characters but doesn’t seem to work. Look at the code below.
$Array = CHtml::listData(MyModel::model()->findAll(array('condition'=>'is_public = 1', 'order'=>'name ASC')),'user_id',mb_convert_encoding('name', 'utf-8', 'IBM-850'));
This code still outputs the wrong format on the characters. Is there another way to solve this?
Keith
(Kburton)
October 25, 2012, 6:40pm
2
All you’ve done is converted the encoding of the string ‘name’, not any of the content.
You probably need to build the array manually in this case:
$records = MyModel::model()->findAll(array('condition'=>'is_public = 1', 'order'=>'name ASC'));
$listData = array();
foreach ($records as $record)
{
$listData[$record->user_id] = mb_convert_encoding($record->name, 'utf-8', 'IBM-850');
}
adde
(Andreas Furst)
October 25, 2012, 6:46pm
3
Good point! Works great, thanks!!