Skip to content

Instantly share code, notes, and snippets.

@sudomaxime
Last active January 31, 2019 12:35
Show Gist options
  • Save sudomaxime/d6a5d64c58ebe0f4e60a03c644a546ad to your computer and use it in GitHub Desktop.
Save sudomaxime/d6a5d64c58ebe0f4e60a03c644a546ad to your computer and use it in GitHub Desktop.
<?php
// Avec cela tu peut compter le nombre d'occurences d'un courriel dans une liste
$list = [
['bon' => true, 'email' => '[email protected]'],
['bon' => true, 'email' => '[email protected]'],
['bon' => false, 'email' => '[email protected]'],
];
$occurence_count = array_count_values(array_column($list, 'email'))
echo $occurence_count['[email protected]]; // outputs 2
// Dans $occurence_count tu vas avoir un array de tous les courriels comme keys, comme value le nombre doccurences,
// Donc quand tu fait ta loop pour imprimer ton csv, dans la colonne prix fait 5 * $occurence_count[<courriel_du_dude>]
// TADAAAA YURE WELCUME !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment