12345678910111213141516171819202122232425262728293031323334 |
- <?php
- //数组转对象
- use App\Services\Base\ErrorCode;
- if(!function_exists('object_array')){
- function object_array($array) {
- if(is_object($array)) {
- $array = (array)$array;
- }
- if(is_array($array)) {
- foreach($array as $key=>$value) {
- $array[$key] = object_array($value);
- }
- }
- return $array;
- }
- }
- if(!function_exists('genApiData')){
- function genApiData( $code = 200, $message = '', $data = '')
- {
- if ($code == 200 && empty($message)) {
- $message = 'success';
- }
- $ret = [
- 'status' => $code,
- 'message' => $message,
- 'data' => $data
- ];
- return json_encode($ret);
- }
- }
|