Class: ArrayUtil
Source Location: /php/lang/ArrayUtil.php
Class ArrayUtil
Class Overview
|
Implements interfaces:
- Iterator (internal interface)
배열을 위한 유틸리티 Wrapper 클래스
// 1. ArrayUtil 생성
new ArrayUtil(array(1,2,3,4,5)); or A_(array(1,2,3,4,5));
// 2. 참조형태 함수 쓰기
$arr = A_(array(5,4,3,2,1));
// 3. 리턴형태 함수 쓰기
$arr = A_(array('a', 'b', 'c', 'd', 'e'));
print_r($arr->map('strtoupper')->return);
// 4. 리턴형태 함수를 참조형태로 쓰기
$arr = A_(array('a', 'b', 'c', 'd', 'e'));
print_r($arr->r(map, 'strtoupper')->to);
or
// 5. 리턴값을 ArrayUtil 객체로 전환해서 쓰기
// object 속성은 return 값으로 받은 배열을 ArrayUtil 로 변환해준다.
$arr = A_(array('a', 'b', 'c', 'd', 'e'));
print ($arr->r(map, 'strtoupper')->object->r(map, 'strtolower')->return);
// 6. 비어있는 ArrayUtil 객체 채우기
$arr = A_()->r(range, 1, 10)->sum();
- 배열관련 함수 목록
1. 참조형태
2. 리턴형태
Located in /php/lang/ArrayUtil.php [line 49]
ArrayObject
|
--ArrayUtil
|
Methods
|
Inherited Properties, Constants, and Methods
|
|
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
-
|
Method Summary
| mixed |
__get() |
return 값 리턴 |
Methods
ArrayUtil __construct(
[
$arr = array()]
)
|
|
생성자
Parameters:
API Tags:
Redefinition of:
- ArrayObject::constructor __construct ( $array )
Parameters:
API Tags:
Redefinition of:
- ArrayObject::append ( $value )
asort
API Tags:
Redefinition of:
- ArrayObject::asort ( )
int count(
[
$mode = 0]
)
|
|
Countable 구현
Parameters:
API Tags:
Redefinition of:
- ArrayObject::count ( )
API Tags:
Implementation of:
- Iterator::current
void display(
[
$var = 'history']
)
|
|
Parameters:
API Tags:
callback getFunction(
string
$method
)
|
|
실제 실행될 함수
Parameters:
|
string |
$method: |
실행될 함수 이름 |
API Tags:
| Return: | 콜백이름 |
| Access: | public |
IteratorAggregate 구현
API Tags:
Redefinition of:
- ArrayObject::getIterator ( )
int getPos(
string
$method
)
|
|
매개변수 위치 얻기
Parameters:
|
string |
$method: |
실행될 함수 이름 |
API Tags:
| Return: | 매개변수 위치 |
| Access: | public |
int hasRef(
string
$method
)
|
|
참조인지 리턴인지 확인
Parameters:
|
string |
$method: |
실행될 함수 이름 |
API Tags:
| Return: | 참조형태, true : 참조, false : 리턴 |
| Access: | public |
API Tags:
Implementation of:
- Iterator::key
ksort
API Tags:
Redefinition of:
- ArrayObject::ksort ( )
natcasesort
API Tags:
Redefinition of:
- ArrayObject::natcasesort ( )
natsort
API Tags:
Redefinition of:
- ArrayObject::natsort ( )
다음 index 전진
API Tags:
Implementation of:
- Iterator::next
void offsetExists(
$index
)
|
|
Parameters:
API Tags:
Redefinition of:
- ArrayObject::offsetExists ( $index )
Parameters:
API Tags:
Redefinition of:
- ArrayObject::offsetGet ( $index )
void offsetSet(
$index,
$value
)
|
|
Parameters:
API Tags:
Redefinition of:
- ArrayObject::offsetSet ( $index, $newval )
void offsetUnset(
$index
)
|
|
Parameters:
API Tags:
Redefinition of:
- ArrayObject::offsetUnset ( $index )
참조가 아닌 상태 함수를 쓸 때 자동으로 참조형태로 전환
// 함수의 속성이 array를 리턴하는 형태이면
// 내부 array를 바꾸고 싶다면 r 메소드를 사용해서 함수를 사용한다.
// 내부 배열을 총 10부터 100까지 인덱스를 1로 채움
$arr = A_()->r(fill, 10, 100, 1);
// 단지 리턴값으로 쓰고 싶으면
$arr = A_()->fill(10, 100, 1);
API Tags:
현재 참조상태 전환
// 아래의 두 코드는 동일하다.
$arr = A_()->ref()->fill(10, 100, 1);
or
$arr = A_()->r(fill, 10, 100, 1);
Parameters:
|
bool |
$is_ref: |
참조 상태, true이면 무조건 참조 적용, 기본값 true, |
API Tags:
API Tags:
Implementation of:
- Iterator::rewind
void setFunctionList(
$name,
$run,
$pos,
$is_reference
)
|
|
Parameters:
|
|
$name: |
|
|
|
$run: |
|
|
|
$pos: |
|
|
|
$is_reference: |
|
API Tags:
uasort
Parameters:
API Tags:
Redefinition of:
- ArrayObject::uasort ( $cmp_function )
uksort
Parameters:
API Tags:
Redefinition of:
- ArrayObject::uksort ( $cmp_function )
API Tags:
Implementation of:
- Iterator::valid
array 관련함수 자동실행
Parameters:
API Tags:
return 값 리턴
return : $this->return
to : $this->to()
object : $this->toObject() // object 속성은 return 값을 ArrayUtil 객체로 반환해준다.
$arr = A_()->fill(10,100,1);
echo $arr->object->sum()->return; // 합계내기
Parameters:
API Tags:
|
|