Skip to main content

All Questions

Tagged with
5 votes
2 answers
349 views

PHP Fisher-Yates shuffle with random_int

The PHP manual states that the regular shuffle() function isn't cryptographically secure, but that random_int() is. I thought, ...
James G.'s user avatar
2 votes
2 answers
102 views

delete multidimentional array value in php

I made a program that converts JSON to a PHP array and checks every value of the multidimensional array with a loop and if a value matches certain values then it deletes that key and value and ...
mahmoudkhani's user avatar
2 votes
1 answer
127 views

function to group data by parent branches

I wrote this function to take database output like from PDO's fetchAll(PDO::FETCH_ASSOC) and turn it into a tree. For small datasets it works well. However, when ...
aswine's user avatar
  • 123
4 votes
3 answers
1k views

Filter an array, but remove the filtered elements

I needed a PHP function that would filter values from one array into a new one, while also removing those values from the original array. After looking through the docs, I didn't see any such function,...
Bee H.'s user avatar
  • 265
0 votes
1 answer
89 views

PHP assign values within in_array

What is a more efficient way of writing this sample code? Its purpose is to create a variable for days of the week based on a numerical value. This data is obtained from user input checkboxes. If the ...
Tim M's user avatar
  • 113
4 votes
2 answers
186 views

Modify a WordPress loop to show posts of certain categories, based on user roles

I've got some code that works as intended, but I have a feeling that it's messy. This code is modifying a wordpress loop and the goal is to check the roles of the current user and show posts of ...
JLW's user avatar
  • 43
1 vote
1 answer
158 views

implode on two level dimensions array

I have an array like this ...
Matías Cánepa's user avatar
3 votes
1 answer
140 views

a php function to check a 'deep' array value

I've just coded a little function to check and get a deep array value. Basically, I need to return the value or null if it's not set or does not exists, or in general not useful for databases records. ...
Luca Reghellin's user avatar
2 votes
2 answers
626 views

remove ALL duplicate elements from an array

I have this code to remove duplicates (all occurrences) from an associative array, does PHP have methods to do this ? Or is there a way to improve the code ? I looked for array_unique, array_search, ...
aurepito's user avatar
3 votes
3 answers
607 views

Find common timeslots for consecutive days

Imagine you want to reserve a classroom over several days. You get a schedule, from the school, telling you when a certain classroom is still free. To make it easy for your students, you want to ...
KIKO Software's user avatar
2 votes
2 answers
2k views

Sort array of dates

I have this array with dates. All the dates are checked before creating the array with preg_match and check_dates. GoodDates ( ...
Nasty Phoenix's user avatar
1 vote
1 answer
2k views

PHP Group associative Array duplicates and make subarrays of different values

I have this type of table: ...
aurepito's user avatar
1 vote
2 answers
102 views

Check URL for keywords [closed]

I'm looking at improving my PHP knowledge and wondering if anybody has any tips on improving and optimising my function below? ...
stu's user avatar
  • 21
2 votes
1 answer
325 views

PHP update multidimensional array values from same path multidmensional array

I need to update a multidimensional array by same key paths of a multidimensional array. I think my code can be better condensed : ...
aurepito's user avatar
2 votes
0 answers
54 views

editing the array I've included instead of editing the file of included array php

In order to reduce time complexity, instead of loading (and then dumping to use it for later) the whole file into an array (It would be O(n) with n=number of lines), I have saved it as array into a ...
Matteo's user avatar
  • 21

15 30 50 per page
1
2 3 4 5
15