Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
Untitled Diff
Créé
il y a 3 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
20 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
23 lignes
Copier tout
25 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
21 lignes
Copier tout
<?php
<?php
Copier
Copié
Copier
Copié
// Turn an array into a key=>value
pair.
Assumes the key is the first item in the sub-array.
// Turn an array into a key=>value
or key=>array
pair.
public function column
_i
nto
_k
eys(array $array): array {
//
Assumes the key is the first item in the sub-array.
public function column
I
nto
K
eys(array $array): array {
// get the name of the column that contains the record id
$key = key($array[0]);
// skip empty arrays
if (! count($array)) return [];
// loop through each result row
foreach($array as $row) {
foreach($array as $row) {
Copier
Copié
Copier
Copié
// pop the
new key
off the top of the array
// pop the
value of the row identifier
off the top of the array
$id = array_shift($row);
$id = array_shift($row);
// O(n)
//
is
there
only one item left in the array
?
//
if
there
is
only one item left in the array
...
if
(count($row) == 1)
$result[$id] =
(count($row) == 1)
//
get the first value
? current($row)
//
...
get the first value
$result[$id] = current(
$row
);
:
$row
;
//
...
get
the rest
of the
array
else
//
get
all
of the
values
$result[$id] = $row;
}
}
Copier
Copié
Copier
Copié
return $result;
return $result;
}
}
Différences enregistrées
Texte d'origine
Ouvrir un fichier
<?php // Turn an array into a key=>value pair. Assumes the key is the first item in the sub-array. public function column_into_keys(array $array): array { // get the name of the column that contains the record id $key = key($array[0]); foreach($array as $row) { // pop the new key off the top of the array $id = array_shift($row); // is there only one item left in the array? if (count($row) == 1) // get the first value $result[$id] = current($row); else // get all of the values $result[$id] = $row; } return $result; }
Texte modifié
Ouvrir un fichier
<?php // Turn an array into a key=>value or key=>array pair. // Assumes the key is the first item in the sub-array. public function columnIntoKeys(array $array): array { // skip empty arrays if (! count($array)) return []; // loop through each result row foreach($array as $row) { // pop the value of the row identifier off the top of the array $id = array_shift($row); // O(n) // if there is only one item left in the array... $result[$id] = (count($row) == 1) ? current($row) // ...get the first value : $row; // ...get the rest of the array } return $result; }
Trouver la différence