I'm working in a cakephp 1.3 project. I have a problem retrieving some data from my database using find('list'). Before my last change I had this code:
$listaHabilidades = $this->Habilidad->find('list',array('fields'=>array('id','habilidad'),'order'=>array('habilidad'))));
This command gives me the next array:
Array
(
[40] => Bicicleta
[42] => enganches de poleas
[28] => Escalada
[43] => transfer
[41] => 4x4
[53] => Administración Linux
[72] => Ángeles
[59] => Baile Flamenco
[57] => Baloncesto
[39] => Barranquismo
[66] => Cante Flamenco
[30] => Conducción
[52] => Consola Linux
[80] => cuarta prueba
[75] => Demonios
[84] => Esgrima
[58] => Futbol
[76] => Limpiar
[77] => Limpiar2
[54] => Linux
[27] => Montañismo
[60] => MS Office
[65] => Natación
[45] => Patinaje
[56] => PC
[78] => probar
[44] => Programación
[82] => Protocolo
[81] => quinta prueba
[63] => Tenis
[79] => tercera prueba
[83] => Triatlón
[55] => W8
[51] => XP
[64] => Zapateado
)
But I had a problem because the data can have spaces at the begining of the field 'habilidad' and I want to get the data without the and order them also without them. So I changed the command to:
$listaHabilidades = $this->Habilidad->find('list',array('fields'=>array('id','trim(Habilidad.habilidad)'),'order'=>array('trim(Habilidad.habilidad)'))));
It gives me the next array:
Array
(
[41] =>
[53] =>
[72] =>
[59] =>
[57] =>
[39] =>
[40] =>
[66] =>
[30] =>
[52] =>
[80] =>
[75] =>
[42] =>
[28] =>
[84] =>
[58] =>
[76] =>
[77] =>
[54] =>
[27] =>
[60] =>
[65] =>
[45] =>
[56] =>
[78] =>
[44] =>
[82] =>
[81] =>
[63] =>
[79] =>
[43] =>
[83] =>
[55] =>
[51] =>
[64] =>
)
How can I get the list trimmed (without loops)?