Jump to: navigation, search

Php parse ini string

From w3cyberlearnings

Contents

PHP function parse_ini_string

This function parses a configuration string not a file. It is similar to parse_ini_file(), and parse_ini_file() parses file.

Syntax parse_ini_string

  • string: is a configuration string
  • section (optional): sets to true will returns multiple array with include the section names. Default sets to false.
  • mode (optional): can either be INI_SCANNER_NORMAL (default) or INI_SCANNER_RAW. If INI_SCANNER_RAW is supplied, then option values will not be parsed.
parse_ini_string(string, section, mode);

Example 1

<?php

define('etc', '/etc/azend342');

// Parse without sections
$file = "SupportTool.ini";
$content = file_get_contents($file);
$ini_array = parse_ini_string($content);
print_r($ini_array);

// Parse with sections
$ini_array = parse_ini_string($content,true);
print_r($ini_array);

?>

Output

Array
(
    [zendpath] => /etc/azend342
    [apachepath] => logs
    [cmd] => netstat -a > netstat.txt
)
Array
(
    [Zend.SupportTool] => Array
        (
            [zendpath] => /etc/azend342
            [apachepath] => logs
            [cmd] => netstat -a > netstat.txt
        )

)

Related Links


basename-- chgrp-- chmod-- chown-- clearstatcache-- copy-- delete-- dirname-- disk_free_space-- disk_total_space-- diskfreespace-- fclose-- feof-- fflush-- fgetc-- fgetcsv-- fgets-- fgetss-- file_exists-- file_get_contents-- file_put_contents- file-- fileatime-- filectime-- filegroup-- fileinode-- filemtime-- fileowner-- fileperms-- filesize-- filetype-- flock-- fnmatch-- fopen-- fpassthru-- fputcsv-- fputs-- fread-- fscanf-- fseek-- fstat-- ftell-- ftruncate-- fwrite-- glob-- is_dir-- is_executable-- is_file-- is_link-- is_readable-- is_uploaded_file-- is_writable-- is_writeable-- lchgrp-- lchown-- link-- linkinfo-- lstat-- mkdir-- move_uploaded_file-- parse_ini_file-- parse_ini_string-- pathinfo-- pclose-- popen-- readfile-- readlink-- realpath_cache_get-- realpath_cache_size-- realpath-- rename-- rewind-- rmdir-- set_file_buffer-- stat-- symlink-- tempnam-- tmpfile-- touch-- umask-- unlink--

Navigation
Web
SQL
MISC
References