I want to reduce my project execution time as tiny as possible. Which is perfect for reducing time In_array or foreach Please let me know and i'll be waiting for the solutions.
in_array When you use foreach loop, PHP will process code. But when you call in_array the C compiled source will do this. So processing binaries is faster than scripting languages.
You shouldn't care about all these micro-optimizations. If you really want to find out the bottlenecks of your application, you should use a profiler. PHP has many array functions. Use the right function for the right job.
If you have to, in_array. Personally I prefer neither. If your array is sorted, using a binary search you can achieve most optimal speeds average speed of (O(log N)). +1 for profiler. If you ever get to work with applications that are already heavily optimized and serve thousands of requests per second, these optimization will make a difference (usually I use the profiler to see what is the slowest functions and how they can be switched with different functions/logic that will make it faster).
I used to fret about the difference between strings defined with "quotes" or 'quotes' and, yes, there is a difference. However once you've worked on a really big system like vBulletin and see how many queries, how much code gets run you'll realise your own app is probably small fry by comparison. You'll probably make bigger gains by ensuring your database is appropriately indexed, your code is well structured and there aren't redundant loops or obsolete code.