I am working on a Laravel 8 blogging application. I need a large numer of articles in order to test the pagination. For this purpose, I have made this factory: The problem Unfortunately, the title column in the articles table is populated with sentences that have a dot at the end. Titles are not supposed to e…
How use array_map for order by word in php
I have this two-dimensional array And I would like this result: I am a beginner, so there may be things that are not done this way. Please understand 😉 I know how to run two foreach one inside the other and look for matches, but I think an array map would be faster and cleaner, right? Maybe I’m wrong ab…
Larave Cache Facade – set vs put
I use Cache::set(…) facade-method for a simple key/value store. But all posts I visit seem to talk about Cache::put(…) method. What is the difference or advantage of one vs the other? Answer set method is same as put As you can see from https://github.com/illuminate/cache/blob/master/Repository.ph…
Finding all 1 digit and 2 digits numbers in a larger number using regex
I want to match all 1 digit and 2 digit numbers using regex. Subject string: ‘12345’ Expected match: 1,2,3,4,5,12,23,34,45 I’m trying: d(d)? but as result i get 12,2,34,3,5 Answer You can use See the PHP demo. Output: NOTES: (?=((d)d?)) – a regex that captures into Group 1 two or one d…
Extract Json data from a countries.csv file on github, and create a seperate array of timezones
Country.csv this is countries.csv file, and i want to extract all the timezones from it, which is its 14th colomn, and the data in there is not properly json formatted. I’m trying to parse the json but it failed. Actually, I want to create an array of timezones like this what i’m doing, is this in…
Trying to run python script in PHP
I’m trying to run a Python script inside a perl script with the following command: On the operating system’s command line, the Python script executes, but when I make a call from a PHP application, the perl work, but the python script don’t work. Answer Do you get any error message from Perl…
Adding values to multidimensional array PHP without overwritting last added value
I’m having trouble with adding values to an associative multidimensional array and echoing them out. The last value added is the one being echoed out. I tried playing with $j next to $dreams[$name] but then it only echoes out the first letter. My code is as follows: Answer You need This creates a new ar…
Remove query string parameter to create a more user-friendly URL
I have this .htaccess file and I have no knowledge with mod_rewrite, What I want to achieve is to have localhost/viewticket/${id} instead of localhost/viewticket.php?id=123 I have tried many .htaccess rules but none worked except this one that hides .php in my URL. Answer I created this one for you, just eras…
Image Preview from DB
I’m Trying to Preview images from database as im saving album in table albums and album images in table images and connecting with relation but i can’t preview the images from table image so i’m adding relations between the 2 tables and trying to preview the images but its not working with m…
VichUploaderBundle in Symfony 6
I hope you can help me because i’m searching and i’m lost 🙁 I’m trying to upload image in my symfony 6 project with VichUploaderBundle. I used the doc : https://github.com/dustin10/VichUploaderBundle/blob/master/docs/usage.md#step-1-configure-an-upload-mapping But i have this error : The cla…