函数分析

WBOY
Release: 2016-06-13 10:35:18
Original
1097 people have browsed it

函数分析求助
小弟新入手php,因对加红语句理解不上,进而对整个函数的功能也就分析不上,求帮助
static public function AssColumn($a=array(), $column='id')
  {
  $two_level = func_num_args() > 2 ? true : false;
  if ( $two_level ) $scolumn = func_get_arg(2);

  $ret = array(); settype($a, 'array');
  if ( false == $two_level )
  {  
  foreach( $a AS $one )
  {  
  if ( is_array($one) )
  $ret[ @$one[$column] ] = $one; else
  $ret[ @$one->$column ] = $one; }  
  }  
  else
  {  
  foreach( $a AS $one )
  {  
  if (is_array($one)) {
  if ( false==isset( $ret[ @$one[$column] ] ) ) {
  $ret[ @$one[$column] ] = array();
  }
  $ret[ @$one[$column] ][ @$one[$scolumn] ] = $one;
  } else {
  if ( false==isset( $ret[ @$one->$column ] ) )
  $ret[ @$one->$column ] = array();

  $ret[ @$one->$column ][ @$one->$scolumn ] = $one;
  }
  }
  }
  return $ret;
  }



------解决方案--------------------
如果$one是一个数组,那么就$ret[ @$one[$column] ] = $one;赋值,否则$one就是对象,就$ret[ @$one->$column ] = $one;赋值
------解决方案--------------------

探讨

如果$one是一个数组,那么就$ret[ @$one[$column] ] = $one;赋值,否则$one就是对象,就$ret[ @$one->$column ] = $one;赋值
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template