- array_map: documentation ( source)
- print_r: documentation ( source)
- explode: documentation ( source)
- array_filter: documentation ( source)
- trim: documentation ( source)
- parse_ini_string: documentation ( source)
<?php
$input = <<<END
[account]
user = {user1}
pwd = {password1}
expdate = 2028-01-01
[account]
user = {user2}
pwd = {password2}
expdate = 2028-01-01
[account]
user = {user3}
pwd = {password3}
expdate = 2028-01-01
END;
$data = array_map(
function($entry) { return parse_ini_string($entry); },
array_filter(
explode('[account]', $input),
function($entry) { return strlen(trim($entry)); }
)
);
print_r($data);
//