In PHP, how do you change the key of an array element?

后端 未结 23 2364
逝去的感伤
逝去的感伤 2020-11-22 03:45

I have an associative array in the form key => value where key is a numerical value, however it is not a sequential numerical value. The key is actually an I

23条回答
  •  死守一世寂寞
    2020-11-22 04:37

    You could use a second associative array that maps human readable names to the id's. That would also provide a Many to 1 relationship. Then do something like this:

    echo 'Widgets: ' . $data[$humanreadbleMapping['Widgets']];
    

提交回复
热议问题