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 array_path($array, $path) { | |
| $context = $array; | |
| $parts = explode('.', $path); | |
| while($key = array_shift($parts)) { | |
| if(!is_array($context)) { | |
| return NULL; | |
| } | |
| if(!array_key_exists($key, $context)) { |
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 foo { | |
| public static function bar() { | |
| return 'foobar'; | |
| } | |
| } |
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 array_partition($array, $callback, $preserveKeys = false) { | |
| $partitions = array(); | |
| foreach($array as $key => $value) { | |
| $partitionName = $callback($value, $key); | |
| if(!array_key_exists($partitionName, $partitions)) { | |
| $partitions[$partitionName] = array(); | |
| } | |
| if($preserveKeys) { |
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 array_partition($array, $callback, $preserveKeys = false) { | |
| $partitions = array(); | |
| foreach($array as $key => $value) { | |
| $partitionName = $callback($value, $key); | |
| if(!array_key_exists($partitionName, $partitions)) { | |
| $partitions[$partitionName] = array(); | |
| } | |
| if($preserveKeys) { |
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 | |
| $foo = new DateTime('2014W08'); | |
| $bar = new DateTime('tuesday this week'); | |
| $diff = $foo->diff($bar); | |
| var_dump($diff->format('%a')); | |
| string(1) "6" |
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 | |
| $arguments = xmlrpc_decode_request($xml, $method); | |
| switch($method) { | |
| case 'get_topic': | |
| $_GET['forum_id'] = $arguments[0]; | |
| $_GET['start_num'] = $arguments[1]; | |
| $_GET['last_num'] = $arguments[2]; | |
| $_GET['mode'] = $arguments[3]; |
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 | |
| /** | |
| * Erste einfache Version. | |
| */ | |
| function naturalDate($timestamp) { | |
| $diff = time() - $timestamp; | |
| if($diff < 86400) { | |
| return 'Heute'; |
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 array_key_rename($array, $old, $new) { | |
| $array[$new] = $array[$old]; | |
| unset($array[$old]); | |
| return $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
| <style> | |
| ul { | |
| display: -webkit-flex; | |
| border-spacing: 4px; | |
| padding: 0; | |
| -webkit-flex-wrap: wrap; | |
| } | |
| li { | |
| width: 12rem; |
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 | |
| $formatter = new MessageFormatter('de', '{comments, plural, =0 {Keine Kommentare} =1 {# Kommentar} other {# Kommentare}}'); | |
| for($comments = 0; $comments < 10; $comments++) { | |
| var_dump($formatter->format(array( | |
| 'comments' => $comments | |
| ))); | |
| } |