I am getting back from a database with an array where I get an array with such values:
Array ([6712] => 64.79.197.36:43444 [6712] => 64.79.197.36:43444 [6711] => 64.79.194.56:41113 [6710] = > 64.21.47.20: 8080 [670 9]) where the number of brackets in the data, [6712] is the "id" field. The problem is that in my script I want to make it So that each array value has a second key that I assign, which is "0" It starts and grows by one, something like this:
Array ([0] [6712] => 64.79.197.36:43444 [1] [6712] => 64.79.197.36:43444 [2] [6711] => 64.79.194.56:41113 [3] [6710] => 64.21.47.20:8080 [4] [670 9])
This is for some data processing, so I want to be able to track every one in a meaningful way within my script (as I can not predict mysql id can be because deleted records etc. May be, so it does not always happen
let me know There are some ways to create a new array by providing the key, but I am thinking that 2 keys are possible for 1 array value
It is quite possible by using references.
But this is likely to prove to be problematic for you to work.
The above code titbit displays an initial array, then allocates another key for each of the three. The value in the initial array then modifies a single entry in the code array, and indicates it That change is reflected in both key values;
Edit
Two keys will be cumbersome to work in an array if you have foreach (), curu (), and other control structure elements You want to use that manipulate your position in the array, because you choose each entry twice.
It may be easier to work with two arrays, the second is the first series of the first indicator.
Then you can work using either $ result or $ wrkResult, and any changes in values in one will be marked again in another; You can loop through one or the other and only get the right number of results, not twice, etc.
Comments
Post a Comment