Skip to content

Commit 5dd96ce

Browse files
committed
Update Format.php
Added a way of formatting the JSON to include the numeric check, but only if the available PHP version supports it (IE v5.3.3 or higher).
1 parent def1295 commit 5dd96ce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

application/libraries/Format.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ public function to_csv()
209209
// Encode as JSON
210210
public function to_json()
211211
{
212-
return json_encode($this->_data);
212+
if (strnatcmp(phpversion(),'5.3.3') >= 0) {
213+
return json_encode($this->_data, JSON_NUMERIC_CHECK);
214+
} else {
215+
return json_encode($this->_data);
216+
}
213217
}
214218

215219
// Encode as Serialized array
@@ -267,4 +271,4 @@ private function _from_serialize($string)
267271

268272
}
269273

270-
/* End of file format.php */
274+
/* End of file format.php */

0 commit comments

Comments
 (0)