root/platform/mysql/mprofile.php/trunk/mpfilter.php @ 34576

Revision 34576, 0.6 kB (checked in by nowelium, 4 years ago)
  • Property svn:executable set to *
  • Property svn:keywords set to Id Revision Date Author
Line 
1#!/usr/bin/env php
2<?php
3
4$replacement = array(
5    '/\r?\n/' => ' ',
6    '/(\"([^\"]+)\")/' => '?',
7    '/(\'([^\']+)\')/' => '?',
8    '/\s{2,}/' => ' '
9
10);
11$replacepattern = array_keys($replacement);
12$replace = array_values($replacement);
13
14$stdin = fopen('php://stdin', 'r');
15while(!feof($stdin)){
16    $line = stream_get_line($stdin, 4096, "\n");
17    $rows = json_decode($line);
18    $returnValue = array();
19    foreach($rows as $row){
20        $returnValue[] = preg_replace($replacepattern, $replace, $row->Info);
21    }
22    echo json_encode($returnValue), PHP_EOL;
23}
Note: See TracBrowser for help on using the browser.