Deriving a new Array from an existing Array:
['■','●','▲'].slice(1, 3) ⟼ ['●','▲']
['■','●','■'].filter(x => x==='■') ⟼ ['■','■']
['▲','●'].map(x => x+x) ⟼ ['▲▲','●●']
['▲','●'].flatMap(x => [x,x]) ⟼ ['▲','▲','●','●']
<?php | |
/** | |
* @param string $regex | |
* @return bool | |
*/ | |
function isValidRegularExpression($regex) { | |
set_error_handler(function() {}, E_WARNING); | |
$valid = preg_match($regex, null) !== FALSE; | |
restore_error_handler(); |
#!/usr/bin/env bash | |
sudo apt update | |
sudo apt -y install curl | |
# Set up PHP 8.0 | |
sudo apt update | |
sudo apt -y install software-properties-common | |
sudo add-apt-repository ppa:ondrej/php | |
sudo apt update |