A parallax effect purely done in CSS, taken from: http://blog.keithclark.co.uk/pure-css-parallax-websites/
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 | |
/** | |
* Check if a value is blank but not zero. | |
* | |
* When you need to accept these as valid, non-empty values: | |
* - 0 (0 as an integer) | |
* - 0.0 (0 as a float) | |
* - "0" (0 as a string) | |
* Use `@is_blank($a['b']);` to avoid notices. | |
* @param mixed $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 | |
/** | |
* Return a formatted string like vsprintf() with named placeholders. | |
* | |
* When a placeholder doesn't have a matching key in `$args`, | |
* the placeholder is returned as is to see missing args. | |
* @param string $string | |
* @param array $kwargs | |
* @param string $pattern | |
* @return string |
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 | |
/** | |
* PHP var_export() with short array syntax (square brackets) indented 2 spaces. | |
* | |
* NOTE: The only issue is when a string value has `=>\n[`, it will get converted to `=> [` | |
* @link https://www.php.net/manual/en/function.var-export.php | |
* @param mixed $expression | |
* @param bool $return | |
* @return string | |
*/ |
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 tidy_html5($html, array $config = [], $encoding = 'utf8') { | |
$config += [ | |
'doctype' => '<!DOCTYPE html>', | |
'drop-empty-elements' => 0, | |
'new-blocklevel-tags' => 'article aside audio bdi canvas details dialog figcaption figure footer header hgroup main menu menuitem nav section source summary template track video', | |
'new-empty-tags' => 'command embed keygen source track wbr', | |
'new-inline-tags' => 'audio command datalist embed keygen mark menuitem meter output progress source time video wbr', | |
'tidy-mark' => 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 | |
function long_datetime($datetime, $level = 7) { | |
$now = new DateTime; | |
$datetime = new DateTime($datetime); | |
$suffix = $now > $datetime ? ' ago' : ' ahead'; | |
$diff = $now->diff($dt); | |
$diff->w = floor($diff->d / 7); | |
$diff->d -= $diff->w * 7; | |
$formats = [ | |
'y' => ' year', |
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 xsd_to_json($xsd_file, $formatted = 448) { | |
$xml_file = preg_replace('/\.xsd$/', '.xml', $xsd_file); | |
$json_file = preg_replace('/\.xsd$/', '.json', $xsd_file); | |
$doc = new DOMDocument(); | |
$doc->preserveWhiteSpace = true; | |
$doc->load($xsd_file); | |
$doc->save($xml_file); | |
$xml = file_get_contents($xml_file); | |
$obj = str_replace($doc->lastChild->prefix.':', "", $xml); |
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 xml_to_array($xml) { | |
return json_decode(str_replace('{}', '""', json_encode(simplexml_load_string($xml))), TRUE); | |
} |
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 | |
// Invalid end tag </s> | |
$html = <<<HTML | |
<table> | |
<tr> | |
<td>123</s></td> | |
<td>456</td> | |
</tr> | |
</table> | |
HTML; |
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 xml_to_json($xml, $formatted=TRUE) { | |
$options = (bool)$formatted ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0; | |
return json_encode(simplexml_load_string($xml), $options); | |
} |