Skip to content

Instantly share code, notes, and snippets.

@64j
64j / switch
Last active January 24, 2022 20:24
Snippet switch
<?php
$switch = !empty($switch) ? $switch : '';
$default = !empty($default) ? $default : '';
$out = '';
if (!empty($params)) {
$out = $default;
foreach($params as $k => $v) {
$value = mb_substr($k, 5);
if (mb_substr($k, 0, 5) === 'case:' && $value === $switch) {
$out = $v;