Good morning, so here is my problem. And sorry in advance if my english isn’t perfect. Anyway, I have a huge amount of relation between numbers formated as so : $relation1 = [1, 2]; $relation2 = [2, …
Tag: algorithm
Why is this addition function sometimes not working in PHP?
I’m currently writing a class to manage time in a specific format. The output is always in this format: 0000:00:0:00:00 which stands for YYYY:WW:D:HH:MM. I have a function to add time and it seemed to …
Get all possible combinations without duplicates
How can I get all the possible combinations of given numbers. For instance I have $arr = [ 1, 2, 3, 4] I want to get the combinations without any duplicates inside the combinations Answer I hope below function work as per your expected output :
How I can create my own pow function using PHP?
I want to create a function in which I put two values (value and its power – Example function: multiply(3, 3) result 27). I have tried so far but failed, I have searched using Google but I have been unable to find any result because I don’t know the name of this function. What I want exactly: 3,3 => 3
Most efficient way to find bidirectional differences between associative arrays
I have a contact array with a set of values which I need to update. I also have a contactChangeLog array that will save the diff between an existing and updated contact. Only the keys which get updated need to be saved to the log. So with 2 contact arrays: I can use array_diff_assoc()… However, I am iterating twice through
Football league scheduling algorithm (with sync. home/away)
I’m making an automatic football league generator and got stuck on schedule. I have an algorithm for generating everything, but not schedule. Take a look: For example: And now when i have got all that data I can just use few foreach() for taking what i need. But – the thing i want is to put teams into RED &
Rotate an array with weekday names as keys to start with tomorrow
I have the following array: I’d like to rotate the elements of this array with the first key being the tomorrow. Let’s say today was Wednesday, I’d want my array to look like this: I already have the weekday available (e.g. a string ‘thursday’). It gets passed into the function that I’m working with. Answer If you convert the day
How to get a 64 bit integer hash from a string in PHP?
I need 64 bit integer hashes of strings for something like a hash map. It seems to me like there is no native PHP hash functionality that can return 64 bit integers? I think it is possible to take the first part of a sha1 hash and convert it to an integer. However that will not bring the best performance
PHP terminal emulator [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. Closed 8 years
Preserve key order (stable sort) when sorting with PHP’s uasort
This question is actually inspired from another one here on SO and I wanted to expand it a bit. Having an associative array in PHP is it possible to sort its values, but where the values are equal to …