Same as Emmerman but don't forget the var
keyword to avoid creating global variables!
And add the check for own property to omit properties from prototypes.
var array = {
'123455': 'kjqs dkjq sdkj ',
'135468': 'msldmsdlv sdml,sdmlcsdc ',
'16554d': 'msljkfhsdlkjfhsmdlkfh'
};
for (var key in array) {
if (array.hasOwnProperty(key)) {
console.log(key, array[key]);
}
}
Besides this I think you're in the wrong language. I think it's done like this in php:
$array = array(
'123455' => 'kjqs dkjq sdkj ',
'135468' => 'msldmsdlv sdml,sdmlcsdc ',
'16554d' => 'msljkfhsdlkjfhsmdlkfh'
);
foreach ($array as $key => $value) {
echo "\$array[$key] => $value.\n";
}
for(i in variable)
beingvariable
your array andi
the key of the array. – acm Apr 20 '11 at 9:30