PHP arrays are ordered mappings, so you should use a Python OrderedDict instead of a regular dict so that the order of insertion gets preserved.
import collections my_dict = collections.OrderedDict([ ('name1', 0), ('name2', 1), ('name3', '2'), ('name4', '11:11'),])
This is the same in PHP of :
my_array = array( "name1" => 0, "name2" => 1, "name3" => '2', "name4" => '11:11' );
If you use just a regular DICT in python, when you make a “for item in my_dict:” the order of iterations is not the order of insertions.