php - Convert Array into Key Value Pair array -


I have a comma separated string that I am exploding in an array. If the array is of unknown length and I want to make it an important value in the pair array where each element in the array is the same key, then how do I do it? I'm assuming that I would have to use array_combine? Can someone give me an example using the array? For example:

  array ([0] => Zebra, [1] => cow, [2] => dog , [3] = & gt; monkey, [4] = & gt; ap)   

in:

  array ([animal] => ; Zebra, [animal] = & gt; cow, [animal] => dog, [animal] => monkey, [animal] => ap)    

You can not use the same key for each element in your array. You need a unique identifier to reach the value of the array. When you use animals for everyone, what price should be used? What can you do to create a 2-dimensional array that you have an array inside the array:

  array ([animals] => array ([0] = & gt; Zebra, [1] = & gt; cow, [2] = & gt; dog, [3] = & gt; monkey, [4] = & gt; ap))   

It is used by $ Array ['animals'] [0]

but still you need number or unique identifier to reach the values ​​of the array.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -