Skip to content
Advertisement

Tag: key

PHP rename the keys of an array

How can I rename keys in an array? Start with this array named $start_array, and change the keys for ‘date’ and ‘revenue’ so you get this $final_array: Here is my terrible attempt which works but is messy. Answer Try the above code.

Search for highest key/index in an array

How can I get the highest key/index in an array with php? I know how to do it for the values. E.g.: from this array I would like to get 10 as an integer value: I know how I could code it but I was asking myself if there is a function for this as well. Answer This should work

Pattern Match on a Array Key

I need to get the stock values out of this array: I need to pattern match on this array, where the array key = “stock” + 1 wildcard character. I have tried using the array filter function to get every other value on the PHP manual but the empty values seem to throw it out. I tried alot of different

Advertisement