Iterate through n bit chunks of a byte string

I have a code like this: $alphabet = array(‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’); $alphabetSize = count($alphabet); $alphabetBitSize = ceil(log($alphabetSize, 2)); $bitSize = $length * $alphabetBitSize; $bytes = random_bytes(ceil($bitSize/8)); What I need is reading $bitSize bits in a loop to generate a latin1 string using the alphabet. Now I am totally lost about how to do this with the $bytes… Read More Iterate through n bit chunks of a byte string

Loop through a table to fetch all records with a particular ID and delete the corresponding files in a folder only deleting one file in folder in php

I tried to query a table to get all records with a particular ID so as to delete the records from the table as well as unlink the corresponding files from a folder on the server but only the first file is getting deleted while all records are getting deleted as it should be. Below… Read More Loop through a table to fetch all records with a particular ID and delete the corresponding files in a folder only deleting one file in folder in php

PHP – how to convert array of values to array with nested keys from values of first array?

I have this array: $input = [‘a’, ‘b’, ‘c’, ‘d’]; the output should be: $output = convertArrayValues($input, ‘final’); $output[‘a’][‘b’][‘c’][‘d’] = ‘final; I need code for convertArrayValues() method which will do the job of converting: $input = [‘a’, ‘b’, ‘c’, ‘d’]; into: $output[‘a’][‘b’][‘c’][‘d’] = ‘final; Dumped array input: array:4 [ 0 => "a" 1 => "b"… Read More PHP – how to convert array of values to array with nested keys from values of first array?

Show images only from checked (checkbox) directory using PHP

$directory = ‘uploads/mainfolder’; mainfolder –subfolder1 –subfolder2 There will be some subfolders inside the folder ‘mainfolder’ ( say subfolder1, subfolder2 etc ) There should be a checkbox infront of subfolder1, subfolder2 etc.. Inside subfolder1, subfolder2 there will be some images So as per checked and submits it should display all the images from the checked directory… Read More Show images only from checked (checkbox) directory using PHP

In PHP how do you send data through a form without any data inputs apart from buttons?

Trying to find out which button the user has pressed. I want to get the value that is in the form-label when the corresponding button is pressed. Is this possible? Thanks index.php <html> <form action="./process.php" method="post"> <?php for ($index = 1; $index <= 10; $index++) { echo "<br>"; echo "<label>$index</label>"; echo "<input type=\"submit\" value=\"Submit\">"; echo… Read More In PHP how do you send data through a form without any data inputs apart from buttons?