php - How to get fully associative array with Zend's fetchPairs() -



php - How to get fully associative array with Zend's fetchPairs() -

my php code follows:

$pairs = $read->select() ->from($eavtable,array('value','entity_id')) ->where('attribute_id=?',$ddid) ->where('store_id=?','0') ->distinct(true); homecoming $read->fetchpairs($pairs);

this code returns php array both string , integer keys. ie:

array(3) { [40003]=> string(6) "246409" ["rootcat"] => string(1) "2" ["10000000888"]=> string(6) "246410" }

i guess string returned when value longer 8 bytes, or when value not numeric. how can "instruct" zend homecoming associative array? 40003 treated string? in database, these values marked varchar.

you can't. in php, if index represented integer (up php_int_max), integer index if effort stringify in quotes:

$array['40003'] = "246409"; $array['40003x'] = "246409"; var_dump($array); array(2) { [40003]=> string(6) "246409" ["40003x"]=> string(6) "246409" }

or type cast:

foreach($array $key => $value) { $result[strval($key)] = $value; } var_dump($result);

same output.

or other trickery:

echo serialize($array); // a:1:{i:40003;s:6:"246409";} //change string index $result = unserialize('a:1:{s:5:"40003";s:6:"246409";}'); var_dump($result);

same output.

php zend-framework

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -