This file contains hidden or 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 | |
private function pdo (): \PDO | |
{ | |
return new \PDO(" | |
mysql:host={$this->config['host']}; | |
port={$this->config['port']}; | |
dbname={$this->config['dbname']}", | |
$this->config['user'], | |
$this->config['pass']); |
This file contains hidden or 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 pipeline ($val, array $pipes) | |
{ | |
foreach($pipes as $pipe) | |
{ | |
$val = $pipe($val); | |
} | |
return $val; |
This file contains hidden or 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 | |
$str = "a bc | |
d e f"; | |
$regex = "/[^\S\n]+/"; | |
$str = preg_replace($regex, " ", $str); | |
echo $str; |
This file contains hidden or 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 | |
$URI = "https://msdn.microsoft.com/en-us/library/system.net.httplistener(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1"; | |
$regex = "(http[s]?:\/\/)?([^\/\s]+\/)(.*)(\?.*[\&]?)"; | |
preg_match("/$regex/", $URI, $match); | |
print_r($match); | |
/* | |
Array |
This file contains hidden or 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 | |
$regex = "(?<function>(?:int)\s*\w+\s*\((?:(?:int)\s*\w+\s*\,\s*){0,}+(?:int)\s*\w+\s*\)\s*\{\s*.*\s*\})"; | |
$str = " | |
int count(int i, int a) | |
{ | |
return i++; | |
} | |
"; |
This file contains hidden or 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 | |
$pattern = "(?<if_all>(?<if>(?:if)\s*\(\s*.*\s*\)\s*\{\s*.*\s*\}\s*)\s*(?<elseif>(?:(?:else if|elseif)\s*\(\s*.*\s*\)\s*\{\s*.*\s*\}\s*){0,}+)\s*(?<else>(?:else)\s*\{\s*.*\s*\}\s*){0,1})"; | |
$haystack = " | |
if(x) | |
{ | |
xxxxx | |
} | |
else if (x) |
This file contains hidden or 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 | |
$arr = [ | |
'Rooms' => [ | |
'1' => [ | |
'name' => 'xxx', | |
'desc' => 'xxx' | |
], | |
'2' => [ | |
'name' => 'yyy', |
This file contains hidden or 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 | |
class Benchmark | |
{ | |
public $time; | |
private $startTime; | |
private $stopTime; | |
public function go($callback) | |
{ |
This file contains hidden or 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 | |
$xml = [ | |
"payments" => [ | |
[ | |
"amount" => "100", | |
"initials" => "ih" | |
], | |
[ | |
"amount" => "1000", |
This file contains hidden or 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
(?:(?<http>http(?:s*)):\/\/(?<host>staging.roomraccoon.com))*(?<path>(?:\/\w*)*)(?<qs>(?:\?\w*=\w*)(?:\&\w*=\w*)) |