Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
Create hash for array irrespective of element order

If I have an array with two elements that I want to sha1 hash, what would be the best way to hash irrespective of the order of the elements. This problem also applies for larger arrays and multidimensional arrays.

So [a=1,b=2] and [b=2,a=1] will return the same hash.

node.js has Object-Hash that does exactly this for example.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Sort the array by keys, then serialize it, then hash that.

ksort($array);
$hash = sha1(serialize($array));
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda