phpDocumentor php-lang
[ class tree: php-lang ] [ index: php-lang ] [ all elements ]

Class: ArrayUtil

Source Location: /php/lang/ArrayUtil.php

Class ArrayUtil

Class Overview

Implements interfaces:

  • Iterator (internal interface)

배열을 위한 유틸리티 Wrapper 클래스

  1.  // 1. ArrayUtil 생성
  2.   new ArrayUtil(array(1,2,3,4,5));    or    A_(array(1,2,3,4,5));
  3.  
  4.  // 2. 참조형태 함수 쓰기
  5.  $arr A_(array(5,4,3,2,1));
  6.  print_r($arr->sort()->to);
  7.  
  8.  // 3. 리턴형태 함수 쓰기
  9.  $arr A_(array('a''b''c''d''e'));
  10.  print_r($arr->map('strtoupper')->return);
  11.  
  12.  // 4. 리턴형태 함수를 참조형태로 쓰기
  13.  $arr A_(array('a''b''c''d''e'));
  14.  print_r($arr->r(map'strtoupper')->to);
  15.  or
  16.  print_r($arr->ref()->map('strtoupper')->to);
  17.  
  18.  // 5. 리턴값을 ArrayUtil 객체로 전환해서 쓰기
  19.  // object 속성은 return 값으로 받은 배열을 ArrayUtil 로 변환해준다.
  20.  $arr A_(array('a''b''c''d''e'));
  21.  print($arr->r(map'strtoupper')->object->r(map'strtolower')->return);
  22.  
  23.  // 6. 비어있는 ArrayUtil 객체 채우기
  24.  $arr A_()->r(range110)->sum();
  25.  print_r($arr->return);

 - 배열관련 함수 목록
 1. 참조형태
 2. 리턴형태

Located in /php/lang/ArrayUtil.php [line 49]

ArrayObject
   |
   --ArrayUtil

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From ArrayObject (Internal Class)

constructor __construct ( $array )
append ( $value )
asort ( )
count ( )
exchangeArray ( $array )
getArrayCopy ( )
getFlags ( )
getIterator ( )
getIteratorClass ( )
ksort ( )
natcasesort ( )
natsort ( )
offsetExists ( $index )
offsetGet ( $index )
offsetSet ( $index, $newval )
offsetUnset ( $index )
setFlags ( $flags )
setIteratorClass ( $iteratorClass )
uasort ( $cmp_function )
uksort ( $cmp_function )

Inherited From ArrayObject (Internal Class)

ARRAY_AS_PROPS = 2
STD_PROP_LIST = 1

[ Top ]
Constant Summary
POS_FIRST   첫번째 매개변수
POS_MAX   마지막 매개변수
POS_SECOND   두번째 매개변수
POS_ZERO   매개변수로 적용 안함

[ Top ]
Method Summary
ArrayUtil   __construct()   생성자
void   append()  
ArrayUtil   asort()   asort
int   count()   Countable 구현
void   current()  
void   display()  
callback   getFunction()   실제 실행될 함수
ArrayUtil   getIterator()   IteratorAggregate 구현
int   getPos()   매개변수 위치 얻기
int   hasRef()   참조인지 리턴인지 확인
void   init()  
void   key()  
ArrayUtil   ksort()   ksort
ArrayUtil   natcasesort()   natcasesort
ArrayUtil   natsort()   natsort
void   next()   다음 index 전진
void   offsetExists()  
void   offsetGet()  
void   offsetSet()  
void   offsetUnset()  
ArrayUtil   r()   참조가 아닌 상태 함수를 쓸 때 자동으로 참조형태로 전환
ArrayUtil   ref()   현재 참조상태 전환
void   rewind()  
void   setFunctionList()  
ArrayUtil   uasort()   uasort
ArrayUtil   uksort()   uksort
void   valid()  
ArrayUtil   __call()   array 관련함수 자동실행
mixed   __get()   return 값 리턴
void   __toString()  

[ Top ]
Methods
Constructor __construct  [line 85]

  ArrayUtil __construct( [ $arr = array()]  )

생성자

Parameters:
   $arr: 

API Tags:
Access:  public


Redefinition of:
ArrayObject::constructor __construct ( $array )

[ Top ]
append  [line 455]

  void append( $value  )

Parameters:
   $value: 

API Tags:
Access:  public


Redefinition of:
ArrayObject::append ( $value )

[ Top ]
asort  [line 213]

  ArrayUtil asort( )

asort


API Tags:
Access:  public


Redefinition of:
ArrayObject::asort ( )

[ Top ]
count  [line 498]

  int count( [ $mode = 0]  )

Countable 구현

Parameters:
   $mode: 

API Tags:
Access:  public


Redefinition of:
ArrayObject::count ( )

[ Top ]
current  [line 472]

  void current( )


API Tags:
Access:  public


Implementation of:
Iterator::current

[ Top ]
display  [line 412]

  void display( [ $var = 'history']  )

Parameters:
   $var: 

API Tags:
Access:  public


[ Top ]
getFunction  [line 379]

  callback getFunction( string $method  )

실제 실행될 함수

Parameters:
string   $method:  실행될 함수 이름

API Tags:
Return:  콜백이름
Access:  public


[ Top ]
getIterator  [line 489]

  ArrayUtil getIterator( )

IteratorAggregate 구현


API Tags:
Access:  public


Redefinition of:
ArrayObject::getIterator ( )

[ Top ]
getPos  [line 369]

  int getPos( string $method  )

매개변수 위치 얻기

Parameters:
string   $method:  실행될 함수 이름

API Tags:
Return:  매개변수 위치
Access:  public


[ Top ]
hasRef  [line 358]

  int hasRef( string $method  )

참조인지 리턴인지 확인

Parameters:
string   $method:  실행될 함수 이름

API Tags:
Return:  참조형태, true : 참조, false : 리턴
Access:  public


[ Top ]
init  [line 93]

  void init( )


API Tags:
Access:  public


[ Top ]
key  [line 468]

  void key( )


API Tags:
Access:  public


Implementation of:
Iterator::key

[ Top ]
ksort  [line 223]

  ArrayUtil ksort( )

ksort


API Tags:
Access:  public


Redefinition of:
ArrayObject::ksort ( )

[ Top ]
natcasesort  [line 233]

  ArrayUtil natcasesort( )

natcasesort


API Tags:
Access:  public


Redefinition of:
ArrayObject::natcasesort ( )

[ Top ]
natsort  [line 243]

  ArrayUtil natsort( )

natsort


API Tags:
Access:  public


Redefinition of:
ArrayObject::natsort ( )

[ Top ]
next  [line 480]

  void next( )

다음 index 전진


API Tags:
Access:  public


Implementation of:
Iterator::next

[ Top ]
offsetExists  [line 439]

  void offsetExists( $index  )

Parameters:
   $index: 

API Tags:
Access:  public


Redefinition of:
ArrayObject::offsetExists ( $index )

[ Top ]
offsetGet  [line 443]

  void offsetGet( $index  )

Parameters:
   $index: 

API Tags:
Access:  public


Redefinition of:
ArrayObject::offsetGet ( $index )

[ Top ]
offsetSet  [line 447]

  void offsetSet( $index, $value  )

Parameters:
   $index: 
   $value: 

API Tags:
Access:  public


Redefinition of:
ArrayObject::offsetSet ( $index, $newval )

[ Top ]
offsetUnset  [line 451]

  void offsetUnset( $index  )

Parameters:
   $index: 

API Tags:
Access:  public


Redefinition of:
ArrayObject::offsetUnset ( $index )

[ Top ]
r  [line 341]

  ArrayUtil r( )

참조가 아닌 상태 함수를 쓸 때 자동으로 참조형태로 전환

  1.   // 함수의 속성이 array를 리턴하는 형태이면
  2.   // 내부 array를 바꾸고 싶다면 r 메소드를 사용해서 함수를 사용한다.
  3.  
  4.   // 내부 배열을 총 10부터 100까지 인덱스를 1로 채움
  5.   $arr A_()->r(fill101001);
  6.   print_r($arr->to);
  7.  
  8.   // 단지 리턴값으로 쓰고 싶으면
  9.   $arr A_()->fill(101001);
  10.   print_r($arr->return);


API Tags:
See:  ArrayUtil::ref()
Access:  public


[ Top ]
ref  [line 314]

  ArrayUtil ref( [bool $is_ref = true]  )

현재 참조상태 전환

  1.  // 아래의 두 코드는 동일하다.
  2.  $arr A_()->ref()->fill(101001);
  3.  or
  4.  $arr A_()->r(fill101001);

Parameters:
bool   $is_ref:  참조 상태, true이면 무조건 참조 적용, 기본값 true,

API Tags:
See:  ArrayUtil::r()
Access:  public


[ Top ]
rewind  [line 460]

  void rewind( )


API Tags:
Access:  public


Implementation of:
Iterator::rewind

[ Top ]
setFunctionList  [line 161]

  void setFunctionList( $name, $run, $pos, $is_reference  )

Parameters:
   $name: 
   $run: 
   $pos: 
   $is_reference: 

API Tags:
Access:  public


[ Top ]
uasort  [line 253]

  ArrayUtil uasort( $cmp_function  )

uasort

Parameters:
   $cmp_function: 

API Tags:
Access:  public


Redefinition of:
ArrayObject::uasort ( $cmp_function )

[ Top ]
uksort  [line 263]

  ArrayUtil uksort( $cmp_function  )

uksort

Parameters:
   $cmp_function: 

API Tags:
Access:  public


Redefinition of:
ArrayObject::uksort ( $cmp_function )

[ Top ]
valid  [line 464]

  void valid( )


API Tags:
Access:  public


Implementation of:
Iterator::valid

[ Top ]
__call  [line 170]

  ArrayUtil __call( $method, $args  )

array 관련함수 자동실행

Parameters:
   $method: 
   $args: 

API Tags:
Access:  public


[ Top ]
__get  [line 285]

  mixed __get( $key  )

return 값 리턴

 return : $this->return
 to     : $this->to()
 object : $this->toObject()

  1.  // object 속성은 return 값을 ArrayUtil 객체로 반환해준다.
  2.  $arr A_()->fill(10,100,1);
  3.  echo $arr->object->sum()->return;   // 합계내기

Parameters:
   $key: 

API Tags:
Access:  public


[ Top ]
__toString  [line 502]

  void __toString( )


API Tags:
Access:  public


[ Top ]
Constants
POS_FIRST = 0 [line 66]

첫번째 매개변수


[ Top ]
POS_MAX = 1000 [line 76]

마지막 매개변수


[ Top ]
POS_SECOND = 1 [line 71]

두번째 매개변수


[ Top ]
POS_ZERO = -1 [line 61]

매개변수로 적용 안함


[ Top ]

Documentation generated on Fri, 09 Apr 2010 11:57:18 +0900 by phpDocumentor 1.4.3