Skip to content

How to keep only unique objects in JSON array | PHP

I have the following JSON array, I would like to adjust the array to only keep unique name values, meaning id could be across numerous objects, but name must be unique, overall Tim and Jacob can only be listed once. The following is what I have currently tried, but it looks at both values in the object, so it…

PHPSESSID cookie lost after redirect

My website redirects user to the payment Gateway page. Once the user has completed the payment, they are redirected back to my website receipt page process.php. Please note that user redirects away from and return to https page. website URL is exactly the same i.e: user redirects away from https://website.com…

Alphabetic ordering for names

I have been struggling with this for almost 2 days now and i just can not get it to work myself. Basically my goal is to make a list from A to Z, with values from a database. Example: Now my php code looks like this: Now, it does work when i put strings inside the array and remove the

How to map a 2D array to 1D array in PHP

I can’t figure out how to do the following array_map in php. Any help is much appreciated. Input: Desired Output: What I have so far: Here I am mapping to an array and I know it’s not what I want but I can not figure out if there is some syntax for me to return just $x[‘slug’] => $x…

reload `procmgr` in container?

So I have a docker container build with buildpack that runs the following command under PID 1 is it possible to reload the configs passed into procmgr somehow? Answer At the time of writing this, no. The procmgr cli that is used here is very basic. https://github.com/paketo-buildpacks/php-web/blob/main/cmd/pr…

PHP MySQL GET RESULT from INSERT INTO IF NOT EXIST

I know how to do INSERT INTO if the record doesn’t exist. But if it does exist, mysql doesn’t treat it as an error. It just treats it as 0 rows inserted. I want to know if that was the case and return that message to the user that the data they submitted already exists. I know I can do