<?php
$string = "username............: username
home directory......: 00/username
mail storage server.: mail-server.example.net
status..............: active
quota size..........: 1000.000 megabytes
quota count.........: no quota
forward to..........: username@example.com
full name...........: testing:testing
offers..............:";
preg_match_all('/\h*([a-z ]+)\.*:\h*(.*)/i', $string, $matches);
$values = array_combine($matches[1], $matches[2]);
var_dump($values);
- Output for 5.2.4 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- array(9) {
["username"]=>
string(8) "username"
["home directory"]=>
string(11) "00/username"
["mail storage server"]=>
string(23) "mail-server.example.net"
["status"]=>
string(6) "active"
["quota size"]=>
string(18) "1000.000 megabytes"
["quota count"]=>
string(8) "no quota"
["forward to"]=>
string(20) "username@example.com"
["full name"]=>
string(15) "testing:testing"
["offers"]=>
string(0) ""
}
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.3
- array(9) {
["username"]=>
string(9) " username"
["ome directory"]=>
string(12) " 00/username"
["mail storage server"]=>
string(24) " mail-server.example.net"
["status"]=>
string(7) " active"
["quota size"]=>
string(19) " 1000.000 megabytes"
["quota count"]=>
string(9) " no quota"
["forward to"]=>
string(21) " username@example.com"
["full name"]=>
string(16) " testing:testing"
["offers"]=>
string(0) ""
}
- Output for 4.4.5 - 4.4.9
- Fatal error: Call to undefined function: array_combine() in /in/vfR0M on line 15
Process exited with code 255. - Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
- Fatal error: Call to undefined function: array_combine() in /in/vfR0M on line 15
Process exited with code 255. - Output for 4.3.0 - 4.3.1
- Fatal error: Call to undefined function: array_combine() in /in/vfR0M on line 15
preferences:
293.7 ms | 401 KiB | 460 Q