I have the following operation which splits a string whenever it encounters an alphabet: I want to extend it in such a way that it splits the string whenever the variable encountered is NOT a number, bracket, plus sign, hyphen, newline or tab. I have written a regex which can match the above: But I need to ne…
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:iaR…
Session put does not seem to be working properly
I’m working with Laravel 5.8 and I wanted to make sure that users can submit a form only every 2 hours (as long as a session is alive). So I tried this at the Controller: So by this, everytime a user submits a new request, session request_has_been_sent must be set. Therefore at the next time user submit…
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&…
XMLHttpRequest and Fetch request to PHP file not working Svelte
I am unable to grab information from a PHP file on an external host using Svelte. Oddly, though, the XMLHTTP request works when linking to a text file hosted on the web. Here is my JS code: <…
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…