Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['delimiter'])&&isset($_GET['input'])) {
- $delimiter = $_GET['delimiter'];
- $arr = explode("\n", $_GET['input']);
- $kvp = array();
- for ($i=0; $i < count($arr) ; $i++) {
- $temp = explode($delimiter, $arr[$i]);
- $temp = array_map('trim', $temp);
- if ($temp[0]!=""&&$temp[1]!=null) {
- if (is_numeric($temp[1])) {
- $temp[1] = doubleval($temp[1]);
- }
- $kvp[$temp[0]] = $temp[1];
- }
- }
- $jsonobj = json_encode($kvp, JSON_UNESCAPED_SLASHES);
- echo $jsonobj;
- }
- ?>
Add Comment
Please, Sign In to add comment