public function modifyJsonStringInArray($data,$jsonfield,$setnewfield=""){
			if (is_array($data)){
				if (count($data) == count($data, COUNT_RECURSIVE)) {
					foreach($data as $value){
						if(!empty($setnewfield)){
							if (is_array($jsonfield)){
								for ($i=0;$i<count($jsonfield);$i++){
									if (isset($data[$jsonfield[$i]])){
										$data[$setnewfield[$i]] = json_decode($data[$jsonfield[$i]]);
									}
								}
							} else {
								if (isset($data[$jsonfield])){
									$data[$setnewfield] = json_decode($data[$jsonfield]);
								}
							}
						} else {
							if (is_array($jsonfield)){
								for ($i=0;$i<count($jsonfield);$i++){
									if (isset($data[$jsonfield[$i]])){
										if (is_string($data[$jsonfield[$i]])) {
                                            $decode = json_decode($data[$jsonfield[$i]]);
                                            if (!empty($decode)) $data[$jsonfield[$i]] = $decode;
                                        }
									}
								}
							} else {
								if (isset($data[$jsonfield])){
                                    $decode = json_decode($data[$jsonfield]);
                                    if (!empty($decode)) $data[$jsonfield] = $decode;
								}
							}
						}
					}
				} else {
					foreach($data as $key => $value){
						$data[$key] = $this->modifyJsonStringInArray($data[$key],$jsonfield,$setnewfield);
					}
				}
			}
			return $data;
		}
public function modifyJsonStringInArray($data,$jsonfield,$setnewfield=""){
			if (is_array($data)){
				if (count($data) == count($data, COUNT_RECURSIVE)) {
					foreach($data as $value){
						if(!empty($setnewfield)){
							if (is_array($jsonfield)){
								for ($i=0;$i<count($jsonfield);$i++){
									if (isset($data[$jsonfield[$i]])){
										$data[$setnewfield[$i]] = json_decode($data[$jsonfield[$i]]);
									}
								}
							} else {
								if (isset($data[$jsonfield])){
									$data[$setnewfield] = json_decode($data[$jsonfield]);
								}
							}
						} else {
							if (is_array($jsonfield)){
								for ($i=0;$i<count($jsonfield);$i++){
									if (isset($data[$jsonfield[$i]])){
										if (is_string($data[$jsonfield[$i]])) {
                                            $decode = json_decode($data[$jsonfield[$i]]);
                                            if (!empty($decode)) $data[$jsonfield[$i]] = $decode;
                                        }
									}
								}
							} else {
								if (isset($data[$jsonfield])){
                                    $decode = json_decode($data[$jsonfield]);
                                    if (!empty($decode)) $data[$jsonfield] = $decode;
								}
							}
						}
					}
				} else {
					foreach($data as $key => $value){
						$data[$key] = $this->modifyJsonStringInArray($data[$key],$jsonfield,$setnewfield);
					}
				}
			}
			return $data;
		}
public function modifyJsonStringInArray ( $ data , $ jsonfield , $ setnewfield = "" ) { if ( is_array ( $ data ) ) { if ( count ( $ data ) == count ( $ data , COUNT_RECURSIVE ) ) { foreach ( $ data as $ value ) { if ( ! empty ( $ setnewfield ) ) { if ( is_array ( $ jsonfield ) ) { for ( $ i = 0 ; $ i < count ( $ jsonfield ) ; $ i ++ ) { if ( isset ( $ data [ $ jsonfield [ $ i ] ] ) ) { $ data [ $ setnewfield [ $ i ] ] = json_decode ( $ data [ $ jsonfield [ $ i ] ] ) ; } } } else { if ( isset ( $ data [ $ jsonfield ] ) ) { $ data [ $ setnewfield ] = json_decode ( $ data [ $ jsonfield ] ) ; } } } else { if ( is_array ( $ jsonfield ) ) { for ( $ i = 0 ; $ i < count ( $ jsonfield ) ; $ i ++ ) { if ( isset ( $ data [ $ jsonfield [ $ i ] ] ) ) { if ( is_string ( $ data [ $ jsonfield [ $ i ] ] ) ) { $ decode = json_decode ( $ data [ $ jsonfield [ $ i ] ] ) ; if ( ! empty ( $ decode ) ) $ data [ $ jsonfield [ $ i ] ] = $ decode ; } } } } else { if ( isset ( $ data [ $ jsonfield ] ) ) { $ decode = json_decode ( $ data [ $ jsonfield ] ) ; if ( ! empty ( $ decode ) ) $ data [ $ jsonfield ] = $ decode ; } } } } } else { foreach ( $ data as $ key => $ value ) { $ data [ $ key ] = $ this -> modifyJsonStringInArray ( $ data [ $ key ] , $ jsonfield , $ setnewfield ) ; } } } return $ data ; }
Modify json data string in some field array to be nice json data structure

Note:
- When you put json into database, then you load it with using PDO:fetch() or PDO::fetchAll() it will be served as string inside some field array.
- So this function is make you easier to modify the json string to become nice json data structure automatically.
- This function is well tested at here >> https://3v4l.org/IWkjn

@param data is the data array
@param jsonfield is the field which is contains json string
@param setnewfield is to put the result of modified json string in new field
@return mixed array or string (if the $data is string then will return string)
Modify json data string in some field array to be nice json data structure