fork download
  1. <?php
  2. $reader = fopen("php://stdin", "r");
  3. $lines = array();
  4. $combined = array();
  5.  
  6. $keys = array ("Name", "Address", "Telephone", "Sex", "Visited exhibition");
  7.  
  8. for ($counter = 0; $buffer = fgets($reader); $counter++) {
  9. $lines[$counter] = explode(" | ", $buffer);
  10. $combined[$counter] = array_combine($keys, $lines[$counter]);
  11. }
  12. print_r($combined);
  13.  
Success #stdin #stdout 0.02s 24400KB
stdin
a | b | c | M | def
1 | 2 | 3 | M | 456
56 | 78 | 91 | M | 23
stdout
Array
(
    [0] => Array
        (
            [Name] => a
            [Address] => b
            [Telephone] => c
            [Sex] => M
            [Visited exhibition] => def

        )

    [1] => Array
        (
            [Name] => 1
            [Address] => 2
            [Telephone] => 3
            [Sex] => M
            [Visited exhibition] => 456

        )

    [2] => Array
        (
            [Name] => 56
            [Address] => 78
            [Telephone] => 91
            [Sex] => M
            [Visited exhibition] => 23
        )

)