Skip to content

Tag: php

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

PHP – Date Format to include a string

I am trying to format a PHP date to be of the following format: Wednesday 3rd November 2021 at 11:01am My code is below: $date = new DateTime($dateOfChange); $date = $date->format(‘l jS F Y “at” g:ia’); I have tried: $date = $date->format(‘l jS F Y “at” g:ia&#82…

How to decode a string in base64 with php

Hello i’m trying to decrypt a base64 string with php and i can’t figure it out. I am able to decrypt it with JavaScript using CryptoJS with the code below What is the equivalent of this code in PHP? Answer To decode and decode from base64 a string can use base64_encode() : and now to decode: Now c…