Skip to content

clang-format equivalent for PHP & HTML

From what I read clang-format is for c/c++/obj-c. Which tool like clang-format would you recommend to automatically format/reformat PHP/HTML code in a consistent way? And why? The use case would be to check code formatting in CI (continuous integration) when submitted through a ‘pull request’ for …

Catch inexistent static files in app.yaml

In app.yaml I have I would like to intercept / redirect non existent image files (gif | png | jpg). As it is, GAE returns an Error not found when requesting some inexistent file with the image extensions, I am looking if there’s some way -at app.yaml- level to intercept them. (I could remove the static …

PHP showing XML calendar data – merge day events

I have the following XML file, which I can’t edit. I am then outputting this using simplexml_load_file($url) into a PHP file: This gives me an output as follows: However, I would like to merge events by date, so the output would be as follows: How can I achieve this without editing the XML file? Thanks!…

Race condition with multiple updates PHP & MySQL

I have a table called cards, Each user can create/have multiple cards. One of the cards must be set as default. Sometimes when a user performs multiple requests to set another card as default at the same time, In the end, There are two or more default cards. Initial table: id user_id is_default 1 50 0 2 50 1 …

Show a date depending on day and time

I have this script that echo’s the upcoming Thursday, unless it’s Wednesday because then it shows the Thursday a week later. This works great. But what I would like is to add a cut-off time on Wednesday on 5PM (17:00 GMT+1 / CEST). So before 5PM it will still show the next Thursday (day after) but…

Missing months in Calendar

I am trying to set values of any missing months in my nested array for specific years. Data: As you can see in the above array, year 2019 and 2018 have missing months. How can I can add those missing months and set the values to zero? Please advice. Answer Use array_replace() to overlay one array with another…

Perfexcrm api return 419 status code, how solve it?

I use perfexcrm api in my web application. As its document I pass the URL in postman and also pass authentication token in headers of postman and company name in params in postman. I try to fetch all customers so I use api/customers as a URL and as a method I use POST for this. But as a output postman