Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

PHP; converts array('123' => 0); into array(123 => 0);

Which I came across as a problem when working with mongodb as it will only except strings as keys (not sure if this is enforced by PHP and/or mongo). Luckily you can create a class with numeric properties and pass that to mongodb which will then be treated as strings i.e

$array = new stdClass; $array->{123} = 0;



> only except strings

A strange feature of the English language is that this doesn't work; you have to use 'accept' here.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: