Skip to content

Tag: php

Regex to select a certain word followed by a integer or decimal?

I need a regular expression to detect the phrase Figure 1.5: in a given string. Also, I intend on using this expression in a PHP preg_replace() function. Here are some more examples: …are given. Figure 2.1: shows that… …are given. Figure 3: shows that… …are given. Figure 1.16: sh…

Import values from temporary table to another table?

I’m joining 3 tables: Currently, I’m fetching the data, build a new array and insert it into my final table. However, I wonder if it’s possible to do this in one go, so basically directly from the temporary table? Answer Yes. Use INSERT . . . SELECT: Note that I introduced table aliases. The…

Cant access Json Array values created by json_decode

My json_decode() is returning an array but i just cant seem to access it. Here’s as much of information i think would be useful. I’m pulling a json value from a server using curl commands. The response (output) from the server : Converting the json formatted string to json array: output: Clearly $…

Update multiple in one query in mysql

I have a problem on how can I update multiple in mysql in just one query the flow here is just like these. This will work and runs correctly What I’ve tried But the problem, it update all of my records into null even if the value of each column is not equal to 0000-00-00 since I’ve been using OR

PHPUnit assertDatabaseHas with Laravel and Inertia

I have a Laravel 8 setup that utilises Intertia.js. I’m trying to test my post routes to store new resources and want to assert that the database has the new record stored, using the assertDatabaseHas() method. Controller.php CreateSlotTest.php When I debug the session I can see the slot that I added to…

check expire time for each verification code

In the code below i check If there is a record for the user Check if ‍‍‍‍‍‍‍‍exprire_at is smaller than it is now, it will expire and create a new code, otherwise show the user a message. But in both cases a new code is created What is the problem Answer change to and to