Skip to content
Advertisement

Performance Improvement: Alternative for array_flip function

Is there any way I can avoid using array_flip to optimize performance. I am doing a select statement from database, preparing the query and executing it and storing data as an associative array in $resultCollection and than I have array op and for each element in $resultCollection am storing its outputId in op[] as evident from the code.

I have explained code and so my question is how can I achieve an similar alternative for array_flip with using array_flip as I want to improve performance.

JavaScript

Advertisement

Answer

You should be able to use the key from the foreach for indexes and build the array pre-flipped like this.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement