I am working on a reporting dashboard for our company intranet site. The function below is selecting all of the jobs and suffix from a table. I'm using PDO fetchall to retrieve my results. the array looks like:
Array
(
[0] => Array
(
[JOB] => 197182
[SUFFIX] => 002
)
[1] => Array
(
[JOB] => M03001
[SUFFIX] => 001
)
[2] => Array
(
[JOB] => 197182
[SUFFIX] => 002
)
)
In this case, the dashboard should have 2 rows, 1 for each job (excluding the duplicate) however how can I search through this array and have it only return a row count of 2 instead of 3? Since there is a duplicate job and suffix I don't want to create a third row with the same job-suffix so it should only be two rows.
function row_count()
{
$conn = new PDO('odbc:GLOBALTST');
$result = $conn->prepare('SELECT JOB, SUFFIX FROM JOBS_IN_PROCESS_G');
$result->execute();
$row = $result->fetchall(PDO::FETCH_ASSOC);
global $count;
$count = count($row);\ if I print this out I get 3
}
question from:
https://stackoverflow.com/questions/66049884/how-to-find-duplicate-array-values-from-pdo-fetchall 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…