
getINIEntries 함수는 INI 파일의 모든 섹션과 키-값 쌍을 읽어오는 함수입니다. 만약 Section1의 모든 키-값 쌍을 읽어오게 되면, 다음과 같은 방법으로 제한할 수 있습니다.
1. Section1의 키-값 쌍만 읽어오기:
getINIEntries 함수를 사용하여 Section1의 키-값 쌍만 읽어오기 위해서는, Section1의 이름을 지정하여 getINIEntries 함수에 전달하면 됩니다.
#hostingforum.kr
php
$ini = new ReflectionExtension();
$section = $ini->getINIEntries('Section1');
print_r($section);
위 코드는 Section1의 모든 키-값 쌍을 읽어와 배열로 반환합니다.
2. 특정 키의 값을 읽어오기:
만약 Section1의 특정 키의 값을 읽어오고 싶다면, getINIEntries 함수를 사용하여 Section1의 키-값 쌍을 읽어온 후, 키의 이름을 사용하여 값을 읽어올 수 있습니다.
#hostingforum.kr
php
$ini = new ReflectionExtension();
$section = $ini->getINIEntries('Section1');
print($section['Key1']);
위 코드는 Section1의 Key1의 값을 읽어와 출력합니다.
3. Section1의 키-값 쌍을 읽어오고, 특정 키의 값을 제외하기:
만약 Section1의 모든 키-값 쌍을 읽어오고, 특정 키의 값을 제외하고 싶다면, getINIEntries 함수를 사용하여 Section1의 키-값 쌍을 읽어온 후, foreach문을 사용하여 특정 키의 값을 제외할 수 있습니다.
#hostingforum.kr
php
$ini = new ReflectionExtension();
$section = $ini->getINIEntries('Section1');
foreach ($section as $key => $value) {
if ($key == 'Key1') {
unset($section[$key]);
}
}
print_r($section);
위 코드는 Section1의 모든 키-값 쌍을 읽어와 Key1의 값을 제외한 나머지 키-값 쌍을 출력합니다.
2025-07-06 20:39