Skip to content

Tag: php

Use php function in php form

I am new in php, I am solving one task. Create a form with 2 text fields to enter only numbers (treat) and will mean number and power. After pressing the button the result is displayed on the same page, and the result is determined by recursive function in case you forget to enter a number, the number 2 will

How to show parent and child items form array in php

I am new at php. Maybe a simple question.. I want to make parent->child view. I have an array like this: With key id and key parent. How to draw in cycle correct structure? Maybe at first I need to create function for creating the tree ? Answer Cycle through the source array $arr to detect records that hav…

Stripe API Update DRAFT invoice for subscription (PHP)

I am using PHP and have a webhook generated with invoice.created. When the invoice is created, Stripe lets the draft invoice sit there for about an hour which gives us time to edit the invoice or adjust it. I use this time to check the database (via webhook) to see how many referrals this person has in the sy…

Laravel: method parameter bypass

In my laravel (7.x) application, I have a method called _index in different controllers & models with exactly same functionality (fetch the data to display in the grid) and parameters (except 1, that requires an additional parameter called available). So, I created a super method in the base controller, s…

php write csv to file returns blank file

I have some csv data that looks like this: When I try to export this csv to a file like this: I get an empty file, what am I doing wrong here Answer From the Symfony docs: https://symfony.com/doc/current/components/http_foundation.html#request If you just created the file during this same request, the file ma…

Decrypt aes-256-cbc encoded file with iv = 0

I have an input.DAT file that is encrypted with aes-256-cbd method. I want to decrypt the file using php. When I execute the following command from command line, the file is decrypted successfully. But when I try to use php for decrypting the file using the method openssl_decrypt($data, AES_256_CBC, $encrypti…

PHP updating multiple elements of sub-array of MongoDB document

I have the following document structure. I am trying to update specific values inside the holes sub-array: Each holes Array element is an Object representing the score on a golf hole, with various properties (fields). I am trying to provide the ability to update the holeGross field ONLY for each score. On my …