How to get last key in an array?

A solution would be to use a combination of end and key (quoting) : end() advances array ‘s internal pointer to the last element, and returns its value. key() returns the index element of the current array position. So, a portion of code such as this one should do the trick : $array = array( … Read more

Import file size limit in PHPMyAdmin

Find the file called: php.ini on your server and follow below steps With apache2 and php5 installed you need to make three changes in the php.ini file. First open the file for editing, e.g.: sudo gedit /etc/php5/apache2/php.ini OR sudo gedit /etc/php/7.0/apache2/php.ini Next, search for the post_max_size entry, and enter a larger number than the size … Read more

Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted

To get the current memory_limit value, run: php -r “echo ini_get(‘memory_limit’).PHP_EOL;” Try increasing the limit in your php.ini file (ex. /etc/php5/cli/php.ini for Debian-like systems): ; Use -1 for unlimited or define an explicit value like 2G memory_limit = -1 Or, you can increase the limit with a command-line argument: php -d memory_limit=-1 composer.phar require hwi/oauth-bundle … Read more

How to get body of a POST in php?

To access the entity body of a POST or PUT request (or any other HTTP method): $entityBody = file_get_contents(‘php://input’); Also, the STDIN constant is an already-open stream to php://input, so you can alternatively do: $entityBody = stream_get_contents(STDIN); From the PHP manual entry on I/O streamsdocs: php://input is a read-only stream that allows you to read … Read more

How can I send an email using PHP?

It’s possible using PHP’s mail() function. Remember the mail function will not work on a local server. <?php $to = ‘nobody@example.com’; $subject=”the subject”; $message=”hello”; $headers=”From: webmaster@example.com” . “\r\n” . ‘Reply-To: webmaster@example.com’ . “\r\n” . ‘X-Mailer: PHP/’ . phpversion(); mail($to, $subject, $message, $headers); ?> Reference: mail