从我的数据库中的目录名称中检索数据
Retrieve data from the name of a directory in my database
我使用 php 和 laravel。我有一个名为 MsgBody 的列。在这一列中,有一个数组如下。我想从此数组中获取“conversationDesc”的值。这个在Controller和blade部分应该怎么办?
"MsgBody": [
{
"MsgType": "TIMCustomElem",
"MsgContent": {
"Desc": "",
"Data": "{\"conversationDesc\":\"abc\",\"deviceType\":\"Android\",\"otherUserMsg\":false,\"sender\":{\"birthday\":\"\",\"city\":\"\",\"coin\":9018,\"diamonds\":990992,\"emotional_state\":\"gizlilik\",\"family_chieftain\":0,\"family_id\":0,\"fans_count\":0,\"focus_count\":1,\"follow_id\":0,\"gameCurrency\":990992,\"gh_status\":0,\"head_image\":\"http://fw25live.oss-cn-beijing.aliyuncs.com/public/attachment/202101/29/16/6013cc8481bbc.png\",\"is_admin\":0,\"is_agree\":1,\"is_authentication\":0,\"is_edit_sex\":0,\"is_guardian\":0,\"is_noble_mysterious\":0,\"is_open_shop\":0,\"is_remind\":1,\"is_vip\":0,\"item\":{\"Yaş\":\"tahmin edersiniz\",\"Medeni durum\":\"gizlilik\",\"Meslek\":\"host\",\"LopMeID\":\"106050\"},\"job\":\"host\",\"levelImageResId\":2131232827,\"login_type\":0,\"luck_num\":\"\",\"luck_num_url\":\"https://test99.lopme.net/wap/index.php?ctl=luck&act=index\",\"members_url\":\"https://test99.lopme.net/wap/index.php?ctl=vip_pay&act=purchase\",\"n_svideo_count\":0,\"nick_name\":\"ibrahimozden\",\"nick_nameFormat\":\"ibrahimozden:\",\"noble_avatar\":\"\",\"noble_barrage\":0,\"noble_car\":0,\"noble_car_name\":\"\",\"noble_car_url\":\"\",\"noble_experience\":0,\"noble_icon\":\"\",\"noble_is_avatar\":0,\"noble_medal\":0,\"noble_name\":\"\",\"noble_silence\":0,\"noble_special_effects\":0,\"noble_stealth\":0,\"noble_vip_type\":0,\"open_podcast_goods\":0,\"pay_car\":\"https://test99.lopme.net/wap/index.php?ctl=car&act=index\",\"podcast_goods\":0,\"podcast_order\":0,\"podcast_pai\":0,\"proUser\":true,\"province\":\"\",\"seconds\":0,\"selected\":false,\"sex\":1,\"sexResId\":2131231724,\"shop_goods\":0,\"shopping_cart\":0,\"showId\":\"106050\",\"show_podcast_goods\":0,\"show_podcast_order\":0,\"show_podcast_pai\":0,\"show_shopping_cart\":0,\"show_svideo\":1,\"show_user_order\":0,\"show_user_pai\":0,\"signature\":\"\",\"society_chieftain\":0,\"society_id\":0,\"society_name\":\"\",\"sort_num\":-1,\"star_box\":\"\",\"stealth\":0,\"ticket\":1806,\"token\":\"\",\"use_diamonds\":9018,\"useable_ticket\":1806,\"user_id\":\"106050\",\"user_level\":25,\"user_order\":0,\"user_pai\":0,\"v_explain\":\"\",\"v_icon\":\"\",\"v_type\":\"0\",\"video_count\":0,\"viewer_guard_type\":0,\"vip_expire_time\":\"Açılmadı\"},\"text\":\"abc\",\"type\":20}",
"Ext": "",
"Sound": ""
}
}
]
你的数据好像是JSON。您可以使用 json_decode
.
对其进行解码
您应该可以通过以下方式访问您想要的内容:
$column = [
"MsgBody" => [
[
"MsgType" => "TIMCustomElem",
"MsgContent" => [
"Desc" => "",
"Data" => "{\"conversationDesc\":\"abc\",\"deviceType\":\"Android\",\"otherUserMsg\":false,\"sender\":{\"birthday\":\"\",\"city\":\"\",\"coin\":9018,\"diamonds\":990992,\"emotional_state\":\"gizlilik\",\"family_chieftain\":0,\"family_id\":0,\"fans_count\":0,\"focus_count\":1,\"follow_id\":0,\"gameCurrency\":990992,\"gh_status\":0,\"head_image\":\"http://fw25live.oss-cn-beijing.aliyuncs.com/public/attachment/202101/29/16/6013cc8481bbc.png\",\"is_admin\":0,\"is_agree\":1,\"is_authentication\":0,\"is_edit_sex\":0,\"is_guardian\":0,\"is_noble_mysterious\":0,\"is_open_shop\":0,\"is_remind\":1,\"is_vip\":0,\"item\":{\"Yaş\":\"tahmin edersiniz\",\"Medeni durum\":\"gizlilik\",\"Meslek\":\"host\",\"LopMeID\":\"106050\"},\"job\":\"host\",\"levelImageResId\":2131232827,\"login_type\":0,\"luck_num\":\"\",\"luck_num_url\":\"https://test99.lopme.net/wap/index.php?ctl=luck&act=index\",\"members_url\":\"https://test99.lopme.net/wap/index.php?ctl=vip_pay&act=purchase\",\"n_svideo_count\":0,\"nick_name\":\"ibrahimozden\",\"nick_nameFormat\":\"ibrahimozden:\",\"noble_avatar\":\"\",\"noble_barrage\":0,\"noble_car\":0,\"noble_car_name\":\"\",\"noble_car_url\":\"\",\"noble_experience\":0,\"noble_icon\":\"\",\"noble_is_avatar\":0,\"noble_medal\":0,\"noble_name\":\"\",\"noble_silence\":0,\"noble_special_effects\":0,\"noble_stealth\":0,\"noble_vip_type\":0,\"open_podcast_goods\":0,\"pay_car\":\"https://test99.lopme.net/wap/index.php?ctl=car&act=index\",\"podcast_goods\":0,\"podcast_order\":0,\"podcast_pai\":0,\"proUser\":true,\"province\":\"\",\"seconds\":0,\"selected\":false,\"sex\":1,\"sexResId\":2131231724,\"shop_goods\":0,\"shopping_cart\":0,\"showId\":\"106050\",\"show_podcast_goods\":0,\"show_podcast_order\":0,\"show_podcast_pai\":0,\"show_shopping_cart\":0,\"show_svideo\":1,\"show_user_order\":0,\"show_user_pai\":0,\"signature\":\"\",\"society_chieftain\":0,\"society_id\":0,\"society_name\":\"\",\"sort_num\":-1,\"star_box\":\"\",\"stealth\":0,\"ticket\":1806,\"token\":\"\",\"use_diamonds\":9018,\"useable_ticket\":1806,\"user_id\":\"106050\",\"user_level\":25,\"user_order\":0,\"user_pai\":0,\"v_explain\":\"\",\"v_icon\":\"\",\"v_type\":\"0\",\"video_count\":0,\"viewer_guard_type\":0,\"vip_expire_time\":\"Açılmadı\"},\"text\":\"abc\",\"type\":20}",
"Ext" => "",
"Sound" => ""
]
]
]
];
$firstMessageContent = $column["MsgBody"][0]["MsgContent"];
$decodedData = json_decode($firstMessageContent["Data"], true);
$conversationDesc = $decodedData["conversationDesc"];
assert($conversationDesc === "abc");
我使用 php 和 laravel。我有一个名为 MsgBody 的列。在这一列中,有一个数组如下。我想从此数组中获取“conversationDesc”的值。这个在Controller和blade部分应该怎么办?
"MsgBody": [
{
"MsgType": "TIMCustomElem",
"MsgContent": {
"Desc": "",
"Data": "{\"conversationDesc\":\"abc\",\"deviceType\":\"Android\",\"otherUserMsg\":false,\"sender\":{\"birthday\":\"\",\"city\":\"\",\"coin\":9018,\"diamonds\":990992,\"emotional_state\":\"gizlilik\",\"family_chieftain\":0,\"family_id\":0,\"fans_count\":0,\"focus_count\":1,\"follow_id\":0,\"gameCurrency\":990992,\"gh_status\":0,\"head_image\":\"http://fw25live.oss-cn-beijing.aliyuncs.com/public/attachment/202101/29/16/6013cc8481bbc.png\",\"is_admin\":0,\"is_agree\":1,\"is_authentication\":0,\"is_edit_sex\":0,\"is_guardian\":0,\"is_noble_mysterious\":0,\"is_open_shop\":0,\"is_remind\":1,\"is_vip\":0,\"item\":{\"Yaş\":\"tahmin edersiniz\",\"Medeni durum\":\"gizlilik\",\"Meslek\":\"host\",\"LopMeID\":\"106050\"},\"job\":\"host\",\"levelImageResId\":2131232827,\"login_type\":0,\"luck_num\":\"\",\"luck_num_url\":\"https://test99.lopme.net/wap/index.php?ctl=luck&act=index\",\"members_url\":\"https://test99.lopme.net/wap/index.php?ctl=vip_pay&act=purchase\",\"n_svideo_count\":0,\"nick_name\":\"ibrahimozden\",\"nick_nameFormat\":\"ibrahimozden:\",\"noble_avatar\":\"\",\"noble_barrage\":0,\"noble_car\":0,\"noble_car_name\":\"\",\"noble_car_url\":\"\",\"noble_experience\":0,\"noble_icon\":\"\",\"noble_is_avatar\":0,\"noble_medal\":0,\"noble_name\":\"\",\"noble_silence\":0,\"noble_special_effects\":0,\"noble_stealth\":0,\"noble_vip_type\":0,\"open_podcast_goods\":0,\"pay_car\":\"https://test99.lopme.net/wap/index.php?ctl=car&act=index\",\"podcast_goods\":0,\"podcast_order\":0,\"podcast_pai\":0,\"proUser\":true,\"province\":\"\",\"seconds\":0,\"selected\":false,\"sex\":1,\"sexResId\":2131231724,\"shop_goods\":0,\"shopping_cart\":0,\"showId\":\"106050\",\"show_podcast_goods\":0,\"show_podcast_order\":0,\"show_podcast_pai\":0,\"show_shopping_cart\":0,\"show_svideo\":1,\"show_user_order\":0,\"show_user_pai\":0,\"signature\":\"\",\"society_chieftain\":0,\"society_id\":0,\"society_name\":\"\",\"sort_num\":-1,\"star_box\":\"\",\"stealth\":0,\"ticket\":1806,\"token\":\"\",\"use_diamonds\":9018,\"useable_ticket\":1806,\"user_id\":\"106050\",\"user_level\":25,\"user_order\":0,\"user_pai\":0,\"v_explain\":\"\",\"v_icon\":\"\",\"v_type\":\"0\",\"video_count\":0,\"viewer_guard_type\":0,\"vip_expire_time\":\"Açılmadı\"},\"text\":\"abc\",\"type\":20}",
"Ext": "",
"Sound": ""
}
}
]
你的数据好像是JSON。您可以使用 json_decode
.
您应该可以通过以下方式访问您想要的内容:
$column = [
"MsgBody" => [
[
"MsgType" => "TIMCustomElem",
"MsgContent" => [
"Desc" => "",
"Data" => "{\"conversationDesc\":\"abc\",\"deviceType\":\"Android\",\"otherUserMsg\":false,\"sender\":{\"birthday\":\"\",\"city\":\"\",\"coin\":9018,\"diamonds\":990992,\"emotional_state\":\"gizlilik\",\"family_chieftain\":0,\"family_id\":0,\"fans_count\":0,\"focus_count\":1,\"follow_id\":0,\"gameCurrency\":990992,\"gh_status\":0,\"head_image\":\"http://fw25live.oss-cn-beijing.aliyuncs.com/public/attachment/202101/29/16/6013cc8481bbc.png\",\"is_admin\":0,\"is_agree\":1,\"is_authentication\":0,\"is_edit_sex\":0,\"is_guardian\":0,\"is_noble_mysterious\":0,\"is_open_shop\":0,\"is_remind\":1,\"is_vip\":0,\"item\":{\"Yaş\":\"tahmin edersiniz\",\"Medeni durum\":\"gizlilik\",\"Meslek\":\"host\",\"LopMeID\":\"106050\"},\"job\":\"host\",\"levelImageResId\":2131232827,\"login_type\":0,\"luck_num\":\"\",\"luck_num_url\":\"https://test99.lopme.net/wap/index.php?ctl=luck&act=index\",\"members_url\":\"https://test99.lopme.net/wap/index.php?ctl=vip_pay&act=purchase\",\"n_svideo_count\":0,\"nick_name\":\"ibrahimozden\",\"nick_nameFormat\":\"ibrahimozden:\",\"noble_avatar\":\"\",\"noble_barrage\":0,\"noble_car\":0,\"noble_car_name\":\"\",\"noble_car_url\":\"\",\"noble_experience\":0,\"noble_icon\":\"\",\"noble_is_avatar\":0,\"noble_medal\":0,\"noble_name\":\"\",\"noble_silence\":0,\"noble_special_effects\":0,\"noble_stealth\":0,\"noble_vip_type\":0,\"open_podcast_goods\":0,\"pay_car\":\"https://test99.lopme.net/wap/index.php?ctl=car&act=index\",\"podcast_goods\":0,\"podcast_order\":0,\"podcast_pai\":0,\"proUser\":true,\"province\":\"\",\"seconds\":0,\"selected\":false,\"sex\":1,\"sexResId\":2131231724,\"shop_goods\":0,\"shopping_cart\":0,\"showId\":\"106050\",\"show_podcast_goods\":0,\"show_podcast_order\":0,\"show_podcast_pai\":0,\"show_shopping_cart\":0,\"show_svideo\":1,\"show_user_order\":0,\"show_user_pai\":0,\"signature\":\"\",\"society_chieftain\":0,\"society_id\":0,\"society_name\":\"\",\"sort_num\":-1,\"star_box\":\"\",\"stealth\":0,\"ticket\":1806,\"token\":\"\",\"use_diamonds\":9018,\"useable_ticket\":1806,\"user_id\":\"106050\",\"user_level\":25,\"user_order\":0,\"user_pai\":0,\"v_explain\":\"\",\"v_icon\":\"\",\"v_type\":\"0\",\"video_count\":0,\"viewer_guard_type\":0,\"vip_expire_time\":\"Açılmadı\"},\"text\":\"abc\",\"type\":20}",
"Ext" => "",
"Sound" => ""
]
]
]
];
$firstMessageContent = $column["MsgBody"][0]["MsgContent"];
$decodedData = json_decode($firstMessageContent["Data"], true);
$conversationDesc = $decodedData["conversationDesc"];
assert($conversationDesc === "abc");