Bifalgorithm post · Computer science one · Iteration

How can you extract array keys and values and compare arrays in PHP?

How can you extract array keys and values and compare arrays in PHP? (Computer science one · Iteration) — "$keys = array_keys($arr);\n\n$vals = array_values($a…

Ideas in this flowchart

  • Opérations sur les tableaux PHP
  • array_keys($arr) extrait les clés du tableau
  • array_values($arr) extrait les valeurs du tableau
  • print_r affiche les tableaux extraits
  • Les clés affichées sont foo, 4, 0 et baz
  • Les valeurs affichées sont 5, bar, 3.14 et ten
  • Les opérateurs d’égalité comparent les tableaux
  • == est l’égalité souple et vérifie les mêmes paires clé-valeur
  • === est l’égalité stricte et exige les mêmes paires, dans le même ordre et du même type
Feed/

How can you extract array keys and values and compare arrays in PHP?

No cover

Channel

Computer science one

1 page

"$keys = array_keys($arr);\n\n$vals = array_values($arr);\n\nprint_r($keys);\n\nprint_r($vals);\n\nwould print Array ( [0] => foo [1] => 4 [2] => 0 [3] => baz ) Array ( [0] => 5 [1] => bar [2] => 3.14 [3] => ten ) Finally, you can use the equality operators, == and === to compare arrays. The first is the loose equality operator and evaluates to true if the two compared arrays have the same key-value pairs while the second is the strict equality operator and is true only if the arrays have the same key/value pairs in the same order and are of the same type."

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.