I have an array: I want to return a json_encode for this array, but only for “key2” and “key3” attributes. For the moment that: But this is not okay as the array may also contain other properties. If it is possible, I prefer not to use loops… (sorry for my english) Answer This so…
Tag: php
PHP DirectoryIterator with natsort
I am retrieving a list if photo files from a directory and echoing into a web page so that the page can be created automatically for any photo album. The following is working fine, but the result is that the photos are not in natural order which is what I’d prefer: ?> Answer The sort category of func…
How can I extract values that have opening and closing brackets with regular expression?
I am trying to extract [[String]] with regular expression. Notice how a bracket opens [ and it needs to close ]. So you would receive the following matches: [[String]] [String] String If I use [[^]]+] it will just find the first closing bracket it comes across without taking into consideration that a new one …
Problem with PHPMailer attaching file (only attaches after page refresh)
I have a script that generates a Certificate upon form submit, as well as sends the generated certificate to the recipients email address. When i enter the details into the HTML form, and submit the form, it fails and comes up with an error saying PHPMailer unable to access the file. But when i click on REFRE…
Apache2 does not show .png images
I just started migrating my code to the google cloud. The server runs Ubuntu but does not display my images (.png). When I open the console and open the link address directly I receive a 404 not found; but when I just go to `http://example.com/icons“I receive a 403 Forbidden message. Could it be the cas…
laravel – Can I add new items to an array that already has some existing items?
var_export($response) is an array like below: The below code gives a result like this: “data”: 3. I wanted add a new item called points with the $response array, into all elements. But here, it overwrites the existing array. How can I achieve this? Expected output: Answer As mentioned, array_push(…
Change login system by API in Laravel 8
I make my first app with API. I am beginner in Laravel and php. I have this migration: and this is my AuthController: Login work’s fine. In addition to the login and password, I need to verify the status column. If status = 1 – then login is possible. How can I do this? Please help me 🙂 How can
unwanted leading space inside data from a table column
a column named story is a text type clicking on a button I have a jquery ajax to get data from that column – on a specific id on server side I have: on client side: everything works problem – there is a leading space before data on both places – bstory and console for example if column conte…
Why doesn’t the message POST
When sending data, an empty value comes in Yii2, why is that? Data post: id, name. JS PHP } Code 200, post null Answer By default the Yii reads post params from $_POST global variable. But web server only parses request of body send as application/x-www-form-urlencoded or multipart/form-data. If you send data…
How to integrate React App With Laravel Sanctum on Apache2
I use React App on localhost:3000 For Laravel API I use apache2 from Laradock and site is: site.localhost To authorize users I use Sanctum Problem is I can not get cookies from sanctum/csrf-cookie (i got them in response header but they are not appear in cookies) and then got 419 code when i try to login via …