How can I force all numeric values to be integer instead of string when some PHP function takes place for exemple with array_replace() ? here is an example:
My $item is an array of default values, which var_dump($item) produces this:
array (size=12)
'id' => string '' (length=0)
'cid' => int 2
'pid' => string '' (length=0)
'rid' => string '' (length=0)
'section' => int 0
'title' => string '' (length=0)
'slug' => string '' (length=0)
'image' => string '' (length=0)
'description' => string '' (length=0)
'ordering' => string '' (length=0)
'created' => string '' (length=0)
'modified' => string '' (length=0)
Then, i call a function to update $item array with new values which comes from db with a function array_replace($item, $item_db);, and when I var_dump($item) again, i get this:
array (size=12)
'id' => string '12' (length=2)
'cid' => string '1' (length=1)
'pid' => string '0' (length=1)
'rid' => string '37' (length=2)
'section' => string '0' (length=1)
'title' => string 'Article2' (length=8)
'slug' => string 'articles123' (length=11)
'image' => string 'e9213e52d235bd892b3337fce3172bed.jpg' (length=36)
'description' => string '' (length=0)
'ordering' => string '3' (length=1)
'created' => string '2014-05-15 14:51:10' (length=19)
'modified' => string '2014-05-15 23:29:40' (length=19)
I want to be all numeric values (id, cid, pid, rid, section, ordering) the integer, except created and modified keys.
How I suppose to do that without manually write each time something like:
$item['section'] = (int) $item['section'];
Is there any solution for this ?