Skip to content

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…

Google Translate Documents php text

I’d like to run thousands of php language keys through Google Translate Documents on https://translate.google.com. The text looks like this: $lang[‘activate_deactivate’] = “Activate / Deactivate&…

Slim framework 4; return Formr-form

In Slim framework 4; How can I return a Formr-form in my controller as a response to a get-request? The code outputs nothing. However, if I uncomment the two lines, it outputs (as expected): Answer From Formr documentations: Formr will automatically echo form elements and messages to the screen, and this is u…

Split assoc array by keys

I have data like this: I want to separate it into 3 different arrays like so: For the life of me i just cant seem to wrap my head around this today, I have tried doing loops and while/if using “array_colum()” but I cant get to add a 0 for the entry that does not have a matching date. PS:

Replacing “/ characters with sed, from within php

I generate password from php (thru web page) using shell_exec / dd/ /dev/urandom. I want to eliminate “/ characters from my generated password. If I do a replacement in my sed line with ‘s/[“/]/!/g’ the script fails to execute. However I tested this from command line like echo “t…

how to pass the selected option as value in moodle select

i want to pass the options as values : here is my code. If i use this means it is looking like below : what i want is the exact value will be pass in to the option values. how to get that Answer You can simplify this with the get records menu functions. https://docs.moodle.org/dev/Data_manipulation_API#get_re…