Using list() function to swap variables values without adding more variables. $url = 'blog:5'; list($type, $id) = explode(':', $url); // in case that the url is 5:block if (!is_numeric($id)) { list($type, $id) = [$id, $type]; }
posted in php by Ivan Gospodinow