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 | |
$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 | |
$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 | |
$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 | |
$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 | |
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 | |
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 | |
class Mapper | |
{ | |
private $instance; | |
function __construct (string $type, string $method, array $data) | |
{ | |
if ($type == 'post') | |
{ |
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
// compile with -std=c++1y | |
#include <algorithm> | |
#include <functional> | |
#include <iterator> | |
#include <vector> | |
namespace LoDash { | |
using std::begin; |
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 | |
/** | |
* Example class | |
*/ | |
class Best | |
{ | |
use Manager; | |
public $name; |