I need help to make it work. I’m using this code for list all json files from folder and paginate it and this works well. But how can I implement sort by getMTime() and krsort()? I want the last modified files at first. Answer Store the mtime values in a separate array, then sort by them with usort. Bef…
Running PHP commands gives Xdebug errors
I’m currently getting some weird error messages whenever I run which php or php –ini: I currently have 4 php versions in my /usr/local/etc/php folders: currently using php7.3 as my default php version. I’m planning to remove older php versions if that doesn’t cause much trouble. Can so…
How to multiple withcount() columns sum and order by in laravel
I have to need to order by records based on withcount() function in laravel 6 In this code, I have two withCount() functions and I need to order By based on that two-column sum before get(). It works when order by using one column but if I use two-column then it returns an unknown column. Is it possible or no…
This is simple php code which displays image chosen from directory, but when I run it, It shows torn image and doesn’t display the actual image
This is simple php code which displays image chosen from directory, but when I run it, It shows torn image and doesn’t display the actual image.. This is the output that I am getting Does anyone know why is this happening? I have tried to run this in all browsers, and it is still showing This is the cod…
SESSION in laravel for page protection
I want to make a Login Registration system in laravel 8. In which User when login only can access a particular page else redirect to login page. I did this like that. what’s wrong in it. //Login Code //Session Code Answer you can use the default authentication in laravel8 using laravel application Jetst…
How can I add a parameter to a callback function like in JavaScript?
I wanted to make a small function that let’s me connect to the database, do something in a callback function and then automatically close the connection like so: Usage would be like this: Is it possible to achieve this somehow? Because my mysqli_conn doesn’t seem to work. How to do it? Answer Supp…
Get dependencies Ids Algorithm
I have this problem and I came out with a solution but what is the best way to solve this problem ? Thank you in advance. Given an array of strings and an array of tasks you need to return a sorted array with tasks and dependencies tasks ids. Example: Expected output: So far this is the solution I built,
PHP | Make a validation check whether the number has a decimal point == x.00 or not
Em, I don’t know how to explain this. I hope you’ll get the point. I’ve variables: From those variables, I want to make a statement as follows: Did you get it? What I want is that when the decimal point of $c is x.00 (like 25.00, 10.00, etc), the $c will be printed. But if the decimal point …
Using an array as request headers in PHP
I’m trying to send a GET request to an API using PHP stream_context_create and file_get_contents. I need to add API keys to the headers of my request, I’m storing these in an array so I easily edit them later and use them in multiple functions. What is a good way to include these arrays as headers…
Can I use the same table to represent different Entities in Symfony?
I am migrating an old PHP project to Symfony. I am trying to create the entities based on the existing database schema which I can not change. I am facing a problem : There is a table that would represent two different entities. Basically, there is a boolean (a tinyint(1)), if the boolean is false, then the r…