you can use $stmt->->fetchAll(PDO::FETCH_ASSOC);
to fetch assoc array.Use below code:
$conn=newPDO("mysql:host=$servername;dbname=$dbname",$username,$password);
$conn>setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$stmt=$conn->prepare("select * from food_package_details where pkg_id=:pkgid");
$stmt->bindparam(":pkgid",$pkg);
$stmt->execute();
$stmt->->fetchAll(PDO::FETCH_ASSOC);
0
solved convert an associative and indexed array into an associative array [closed]