Category "php"

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

I would like to take an array like this and combine it into 1 single array. array (size=2) 0 => array (size=10) 0 => string '1'

Using underscore before public function names

I was just reading some code and I came across a function named __toString. Here is the function prototype: public function __construct($par) What is the reaso

Parameter is not sent to Laravel route in Ajax

I'm working with Laravel 5.8 and I wanted to apply a discount code system for my site. So I tried sending data with Ajax like this: $.ajax({ type: 'POST',

Read users and passwords from a txt file

I have a txt file which looks like this USER: user46226234 PASS: #)(HF(WE*FHWE USER: user49503420594 PASS: yellowbird USER: user449202934 PASS: dog I'm trying

How to prevent phpmailer sending embedded image as an attachment on Gmail?

I am sending an email with the logo of a company in it. However, I find it annoying when it shows the .png file on the list of emails on Gmail. Upon clicking th

PHP header location absolute URL

I came across an issue where an absolute path set in header location wouldn't work but pointing to the file itself did. This only affected a few customers. One

PHP usort() order in case of equality

In the PHP manual for usort(), it states: If two members compare as equal, their relative order in the sorted array is undefined. Also, A new sort al

Laravel: Why is my variable not being set while it's in the construct function of the controller?

class Controller extends BaseController { use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests; private $host; private

Count number of slides of ppt file in php

I am trying to get the number of slides of a ppt file. I am getting the number of slides sometimes but sometimes it will not give me the count. I don't get what

Spam Filter in Contact Form

With an HTML contact form such as HTML contact form <h1>Contact Form</h1> <p>Please fill in the following details and click on SEND.</p&g

Starting a large PHP project. Is OOP necessary or is it just a preference?

I started learning PHP awhile ago. I guess I'm fairly okay in it. I want to write a Content Management System, just as a project for myself, however long it may

Two buttons one form

<?=form_open('blog/register');?> <table> <tr> <td><label for="register_name">User

How to save php socket resource in database?

I am creating a socket in php with socket_create and would like to store the received socket in a database (to access from other php code). However the socket i

Prestashop cUrl Login

I'm trying to log-in as customer using cUrl method in Prestashop. When I send my cUrl request, my values are inserted in the log-in form but the form is not s

PHP, Returning to a calling Page after saving a record in a Edit page

Lets say I have a Page with a List (list.php). I click on a row on that list to Edit that record. I go to a edit.php Page. I have 3 buttons on that edit.php pag

protect my blog content

Good evening, is there any way to protect my blog content (text-picture) from copy/paste. I've tried Javascript, but it's easy to desactivate it. Any magical

Remove categories with all childs derived from parent category

I want to remove all related child categories from parent categories. I think I need a recursive function to solve this. Here is my attempt: public function de

send email using gmail-api and google-api-php-client

I am using https://github.com/google/google-api-php-client and I want to send a test email with a user's authorized gmail account. This is what I have so far

GA4 custom event from server side, can someone tell me how i can do the following code in php?

const measurement_id = `G-XXXXXXXXXX`; const api_secret = `<secret_value>`; fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measureme

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

After upgrading Ubuntu from 14.04 to 16.04, PHP CLI started complaining about xdebug: $ php -v Cannot load Xdebug - it was already loaded PHP 7.0.13-0ubuntu0.1