This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = range(1, 4); | |
$example = [1,2,3,4,5,6,3,7]; | |
$a = $example; | |
print_r(array_reduce( | |
$a, | |
// (..) ==1, ==1 | |
function ($carry, $item) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function flipFlop2(): \Generator | |
{ | |
$switch = false; | |
while (true) { | |
$value = yield; | |
// condition1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Usage: MVC_ROUTE_FILE=routes.php php -S localhost:8000 mvc.php | |
Need to move into views/ directory those files named views_* | |
*/ | |
foreach (require getenv('MVC_ROUTE_FILE') as $routePattern => $dispatch) { | |
if (preg_match($routePattern, $_SERVER['REQUEST_URI'], $arguments)) { | |
$dispatch(...$arguments); | |
exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* with operator for PHP */ | |
function with(&$obj, $properties) | |
{ | |
foreach ($properties as $property => $value) | |
{ | |
$obj->$property = $value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Http\Controllers; | |
use File; | |
use App\Http\Requests; | |
use Illuminate\Http\Request; | |
class HomeController extends Controller | |
{ | |
/** | |
* Create a new controller instance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function arrToStr(array $a) | |
{ | |
if (empty($a)) return '[]'; | |
foreach($a as $k => $v) | |
{ | |
if (is_array($v)) | |
$a[$k] = arrToStr($v); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* tedious version 0.1 | |
* | |
* Simple script to return php configuration | |
*/ | |
#settings | |
$password = 'ablabla'; | |
// some password protection | |
if ($_GET['pass'] != $password) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Script to randomly pick a file and echo it, or return the filename | |
* | |
*/ | |
# data | |
$_helpScreen = <<<OUT | |
Random File Picker Help | |
-=-=-=-==-=-=--==-=-=-=- |