为嵌套数组赋值变量并将其拆分

I am getting nested array reply. It is contain date, time and day I want to break that. How can i do that.

This is my reply

Array
(
    [code] => 202
    [message] => Accepted
    [data] => Array
        (
            [result] => Array
                (
                    [15:45~31-10-2016 Mon] => Array
                        (
                            [Sday] => 
                            [Ttime] => 15:45
                            [Smonth] => 

"[15:45~31-10-2016 Mon] => Array" how to assign variable and how can i break this into day ,date and time variable

If you have only single element in result array, use extract and explode to retrieve the values from man array: Something like -

$result = $array['data']['result'];
$date = key($result);
$day = extract($result[$date]);

var_dump($date); // 15:45~31-10-2016 Mon

var_dump($Ttime); // will output 15:45
$date = explode(' ', $date);
$dateString = substr($date[0], strpos($date[0], "{$Ttime}~") + 1); //31-10-2016
$week = $date[1]; // var_dump($week); will give `Mon`

As mentioned in Mohammad's comment on your question,

You should use preg_split function.

$str = key($array['data']['result']); // 15:45~31-10-2016 Mon
$res = preg_split("/[~\s]/", $str);
echo '<pre>'; print_r($res);

output:-

Array
(
    [0] => 15:45
    [1] => 31-10-2016
    [2] => Mon
)

Given:

$result = array(
    'code' => '202',
    'message' => 'Accepted',
    'data' => array(
        'result' => array(
            '15:45~31-10-2016 Mon' => array(
                'Sday' => '',
                'Ttime' => '15:45',
                'Smonth' => ''
            )
        )
    )
);

you can do this:

$data = $result['data']['result'];
$dateKey = key($data);
$dateString = preg_split("/[~\s]/", $dateKey);
$date = array(
    'day' => $dateString[2],
    'date' => $dateString[1],
    'time' => $dateString[0]
);
var_dump($date);

or this:

$data = $result['data']['result'];
$dateKey = key($data);
$dateString = preg_replace("/[~\s]/", ' ', $dateKey);
$dateObj = DateTime::createFromFormat('H:i d-m-Y D', $dateString);
$date = array(
    'day' => $dateObj->format('D'),
    'date' => $dateObj->format('m-d-Y'),
    'time' => $dateObj->format('H:i')
);
var_dump($date);