corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-07 4ce2a5a2545b4c2f53b3404302071e5eab63592a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
 
class Router {
    private array $routes = [];
    
    public function add(string $path, array $params = []): void {
        $this->routes[] = [
            "path"=> $path,
            "params"=> $params
        ];
 
 
    }
    public function match (string $path,): array|bool {
        foreach ($this->routes as $route) {
            if ($route["path"] === $path) {
                return $route["params"];
            }
        }
        return false;
    }
}