Yes, csv is simple BUT if you want it readable in Excel (at least on Windows), you need to prepend it with a hidden BOM and as UTF8. Tried every possible suggestions in stackoverflow that says it works BUT it doesn't. So, try the phpoffice approach. It works for me... Install 1~$ cd /an/isolated/directory 2~$ composer …
Read MoreOverview In contrast to a named function like: 1<?php 2function multiply($x, $y) 3{ 4return $x * $y; 5} An anonymous or unnamed-function, well has no name: 1<?php 2function ($x, $y) { 3return $x * $y; 4}; //closing semicolon here is mandatory. NOTE: semicolon after the closing curly bracket is mandatory as it is …
Read MoreSuppose that you have an array that holds the lengths of squares: 1<?php 23$lengths = [10, 20, 30]; To calculate the areas of the squares, you may come up with the foreach loop like this: 1<?php 23$lengths = [10, 20, 30]; 45// calculate areas 6$areas = []; 78foreach ($lengths as $length) { 9$areas[] = $length * …
Read MoreCallbacks can be denoted by the "callable" type declaration. Example: 1icasimpan$ nl -ba callable_example.php 21 <?php 32 function printFormatted(callable $format, $str) { 43 echo $format($str); 54 echo "<br>"; 65 } 76 87 function exclaim($str) { return $str . "!"; } 98 …
Read MoreAn iterable is any value which can be looped through with a foreach() loop. The iterable pseudo-type was introduced in PHP 7.1, and it can be used as a data type for function arguments and function return values. Example 1<?php 2function printIterable(iterable $myIterable) { 3foreach($myIterable as $item) { 4echo …
Read MoreThis is quite confusing but as soon as you see the logic, it would make sense. Say you have this code: 1<?php 23$my_var= 'title'; 4$$my_var = 'PHP variable variables'; // $my_var has a value of 'title'. So the 2nd '$' makes it $title 5echo $title; // ...so, YOU see now where you will …
Read MoreThere's what is called a "Data Structure" or DS package available in packagist. Install 1~$ cd /an/isolated/directory 2~$ composer require php-ds/php-ds 3~$ composer install Try this code: 1<?php 2require __DIR__ . '/vendor/autoload.php'; 345$stack = new \Ds\Stack(); 6//$stack = new Stack(); …
Read MoreAs of php7.4, php arrow function was added as a more concise syntax for anonymous functions. Basic syntax: 1fn (arguments) => expression; Is functionally equivalent to the following anonymous function: 1function(arguments) { return expression; } Unlike anonymous functions, arrow functions can automatically access …
Read MoreHere is a curated links of sites that are I think are useful as I learn or relearn PHP, Laravel and Symfony further. Incomplete of course but there's always the internet. Will add any that are worthy to be linked here. For now, this would suffice. If you think there are links worthy to be added here, let me know in the …
Read More1composer remove Vendor/Package_Name See https://stackoverflow.com/questions/23126562/how-to-remove-a-package-from-laravel-using-composer
Read More