Guest User

Untitled

a guest
Jul 2nd, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2. if(isset($_GET['delimiter'])&&isset($_GET['input'])) {
  3.     $delimiter = $_GET['delimiter'];
  4.     $arr = explode("\n", $_GET['input']);
  5.     $kvp = array();
  6.     for ($i=0; $i < count($arr) ; $i++) {
  7.         $temp = explode($delimiter, $arr[$i]);
  8.         $temp = array_map('trim', $temp);
  9.         if ($temp[0]!=""&&$temp[1]!=null) {
  10.             if (is_numeric($temp[1])) {
  11.             $temp[1] = doubleval($temp[1]);
  12.         }
  13.         $kvp[$temp[0]] = $temp[1];
  14.         }
  15.     }
  16.     $jsonobj = json_encode($kvp, JSON_UNESCAPED_SLASHES);
  17.     echo $jsonobj;
  18. }
  19. ?>
Add Comment
Please, Sign In to add comment