Home >Backend Development >PHP Tutorial >How to remove value keys from one-dimensional array and two-dimensional array in PHP

How to remove value keys from one-dimensional array and two-dimensional array in PHP

小云云
小云云Original
2018-03-29 15:47:392107browse

This article mainly shares with you the method of removing the value key of one-dimensional and two-dimensional arrays in PHP. It mainly explains it to you in the form of code. I hope it can help you.

  • Two-dimensional array removes duplicate value keys

private function array_unique_fb($origin){
  foreach ($origin as $key => $v){  $v = json_encode($v);  $temp[$key] = $v;
  }  $temp = array_unique($temp);  foreach ($temp as $k => $val){  $temp[$k] =json_decode($val,true);
  }  return $temp;
}
  • One-dimensional array can be directly array_unique

The above is the detailed content of How to remove value keys from one-dimensional array and two-dimensional array in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn