慕容森
您可以通过多种不同的方式来做到这一点,看看不同的方法及其演示。使用extract(),<?php$str = '{"Confirmation":"200710035843DH4","Message":"success","Status":"success"}';extract(json_decode($str,true));echo $Confirmation;?>演示: https: //3v4l.org/3U43b使用foreach(),<?php$str = '{"Confirmation":"200710035843DH4","Message":"success","Status":"success"}';$array = json_decode($str,true);foreach ( $array as $key => $value ) { $$key = $value; }echo $Confirmation;?>演示:: https : //3v4l.org/jLnRE使用(从php 7.1array destructure开始),<?php$str = '{"Confirmation":"200710035843DH4","Message":"success","Status":"success"}';['Confirmation'=>$confirmation, 'Message'=>$message, 'Status'=>$status] = json_decode($str,true);echo $confirmation;?>演示: https: //3v4l.org/rrFa8使用list(),<?php$str = '{"Confirmation":"200710035843DH4","Message":"success","Status":"success"}';list('Confirmation'=>$confirmation, 'Message'=>$message, 'Status'=>$status) = json_decode($str,true);echo $confirmation;?>演示: https: //3v4l.org/Zpt60