Skip to content
Advertisement

Tag: arrays

explode an array of delimited strings into two arrays

I have the following array: that I need to split into two arrays using “-” as delimiter: and Is there anything like array_explode that does what I want? or a combination of php array functions? I’d like to do this without going through my own for/each loop, if possible, or at least minimize having to reinvent the wheel when something

Check if all values in array are the same

I need to check if all values in an array equal the same thing. For example: If every value in the array equals ‘true’ then I want to echo ‘all true’. If any value in the array equals ‘false’ then I want to echo ‘some false’ Any idea on how I can do this? Answer All values equal the test

Storing application permissions in a database

I’m developing an application for our company that eventually will have lots of ways of restricting users to particular sections/modules. While the application is still small, I’d like to move to a new method of storing permissions that, as the application grows, will remain easy to maintain and query. Currently in our MySQL database we have a table called “user”

Best way to clear a PHP array’s values

Which is more efficient for clearing all values in an array? The first one would require me to use that function each time in the loop of the second example. foreach ($array as $i => $value) { …

Remove all array elements except what I want?

I have controller that takes post parameters from HTML form, it will then send them to model that will insert the array into Cassandra database. It is SQLInjection proof, because it’s NoSQL, however what I’m afraid is that user can just simulate 100k post parameters or just add some that I don’t need and it will be inserted into database.

Advertisement