PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php class Type { function __construct(public readonly string $code) {} public function getCode(): string { return $this->code; } } $types = [ new Type('code'), new Type('mode'), new Type('stop') ]; var_dump(array_search(fn($type) => $type->getCode() === 'mode', $types));
Show:  
Copy Clear