<?php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; class HomeController extends AbstractController { #[Route('/search/{id}', name: 'home_search')] public function search(int $id): Response { $array = [ ['id'=>10, 'name'=>'Jhon', 'age'=>23], ['id'=>32, 'name'=>'Alex', 'age'=>34], ['id'=>54, 'name'=>'Bob', 'age'=>45], ['id'=>6, 'name'=>'Mike', 'age'=>61], ]; $rowId = array_search($id, array_column($array, 'id')); return $this->json($rowId); } #[Route('/', name: 'home')] public function home(): Response { return $this->redirectToRoute('home_search', [ 'id' => 32 ]); } }