I am trying to decode some JSON into a php array. Here's the code excerpt: 

```
$getfile="{"fname":"bob","lname":"thomas","cascade":"bthomas","loc":"res","place":"home 2"}";
$arr = json_decode($getfile, true);
$arr['day3'] = $selecter;
echo(print_r($arr));

```

The only thing that gets returned is '1'. I've checked JSONLint and it is valid json, so I'm wondering why json\_decode is failing. I also tried checking what the array is before adding the day3 key to it, and I still return a '1'. Any help is appreciated!

Actual code:

```
$getfile = "";
    $getfile = file_get_contents($file);
    if ($getfile == "") {
        writeLog("Error reading file.");
    }
    writeLog("getfile is " . $getfile);
    writeLog("Decoding JSON data");
    $arr = json_decode($getfile, true);
    writeLog("Decoded raw: " . print_r($arr));
    writeLog("Editing raw data. Adding data for day " . $day);
    $arr['day3'] = $selecter;
    writeLog(print_r($arr));
    $newfile = json_enconde($arr);
    writeLog($newfile);
    if (file_put_contents($file, $newfile)) {
        writeLog("Wrote file to " . $file);
        echo $newfile;
    } else {
        writeLog("Error writting file");
    }

```

These are the contents of $file (it's a text file)

```
{"fname":"Bob","lname":"Thomas","cascade":"bthomas","loc":"res","place":"home 2"}

```