提问人:Md Arif 提问时间:5/29/2022 更新时间:5/29/2022 访问量:54
wordpress stdClass Object 元素 如何打印php字符串 [已关闭]
wordpress stdClass Object elements how to print php string [closed]
问:
如何打印selection_items下的选项
Array
(
[id] => 19
[is_core_field] => 0
[order_num] => 19
[name] => Accommodation Amenities
[slug] => accommodation_amenities
[description] =>
[type] => checkbox
[icon_image] =>
[is_required] => 0
[is_configuration_page] => 1
[is_search_configuration_page] => 1
[is_ordered] => 0
[is_hide_name] => 0
[for_admin_only] => 0
[on_exerpt_page] => 0
[on_listing_page] => 1
[on_search_form] => 1
[on_map] => 0
[advanced_search_form] => 0
[categories] => a:6:{i:0;s:4:"2801";i:1;s:4:"2874";i:2;s:4:"2852";i:3;s:4:"2849";i:4;s:4:"2850";i:5;s:4:"2851";}
[options] => a:4:{s:15:"selection_items";a:153:{i:5;s:23:"24-Hour Guest Reception";i:60;s:16:"24-Hour Security";i:138;s:18:"Accessible Parking";i:55;s:7:"Adapter";i:122;s:17:"Additional Toilet";i:30;s:16:"Air Conditioning";i:123;s:17:"Allergy-free room";i:142;s:11:"ATM On-Site";i:61;s:27:"Babysitting/child services ";i:46;s:7:"Balcony";i:48;s:8:"Bathrobe";i:45;s:7:"Bathtub";i:39;s:10:"Bar/Lounge";i:148;s:10:"Beachfront";i:84;s:9:"Body Soap";i:35;s:12:"Bridal Suite";i:13;s:17:"Business Services";i:25;s:18:"Cable/Satellite TV";i:27;s:4:"CCTV";i:56;s:20:"Cleaning Commodities";i:57;s:12:"Clothes Rack";i:14;s:23:"Complimentary Breakfast";i:6;s:24:"Complimentary Toiletries";i:32;s:9:"Concierge";i:116;s:11:"Conditioner";i:20;s:25:"Cribs & Cots for Children";i:22;s:19:"Curated Experiences";i:21;s:13:"Custom Offers";i:78;s:23:"Designated Smoking Area";i:132;s:8:"Detached";i:90;s:11:"Dining Area";i:118;s:23:"Drying Rack for Clothes";i:64;s:15:"Electric Kettle";i:11;s:20:"Electronics Chargers";i:36;s:15:"Elevator Access";i:114;s:35:"Entire Unit located on Ground Floor";i:17;s:25:"Exercise Facilities (Gym)";i:40;s:23:"Executive Lounge Access";i:96;s:26:"Express Check in/Check Out";i:92;s:12:"Family Rooms";i:49;s:3:"Fan";i:113;s:14:"Feather Pillow";i:44;s:17:"Fire Extinguisher";i:155;s:13:"First Aid Kit";i:8;s:17:"Flexible Checkout";i:152;s:44:"Food can be Delivered to Guest Accommodation";i:26;s:19:"Free Early Check-in";i:3;s:12:"Free Parking";i:2;s:9:"Free WIFI";i:77;s:6:"Fruits";i:93;s:6:"Garden";i:130;s:11:"Garden View";i:71;s:9:"Gift shop";i:115;s:5:"Grill";i:83;s:9:"Hairdryer";i:131;s:38:"Hand sanitizer in guest accommodation ";i:124;s:26:"Hardwood or Parquet Floors";i:7;s:17:"Healthy Breakfast";i:149;s:9:"Hot Water";i:157;s:7:"Heating";i:24;s:12:"Housekeeping";i:58;s:21:"Hypoallergenic pillow";i:103;s:23:"Increased Accessibility";i:125;s:20:"Inner Courtyard View";i:62;s:32:"Interconnected room(s) available";i:137;s:22:"Iron and Ironing Board";i:99;s:15:"Ironing Service";i:38;s:15:"Key Card Access";i:41;s:10:"Kids Meals";i:128;s:19:"Kid-friendly Buffet";i:156;s:28:"Kid activities/ Kid Friendly";i:33;s:11:"Kitchenette";i:94;s:13:"Landmark View";i:150;s:11:"Laptop Safe";i:15;s:16:"Laundry Services";i:67;s:6:"Linens";i:146;s:7:"Lockers";i:76;s:26:"Meeting/Banquet facilities";i:29;s:9:"Microwave";i:63;s:13:"Mountain View";i:89;s:12:"Mosquito Net";i:18;s:9:"Newspaper";i:54;s:15:"No Pets Allowed";i:120;s:22:"No Single-Use Plastics";i:53;s:10:"No Smoking";i:109;s:18:"Non-Feather Pillow";i:119;s:27:"Non-Smoking Rooms Available";i:28;s:18:"On-site Restaurant";i:70;s:17:"Outdoor furniture";i:98;s:19:"Outdoor Dining Area";i:121;s:4:"Oven";i:153;s:17:"Outdoor Fireplace";i:95;s:14:"Packed Lunches";i:80;s:11:"Pants Press";i:23;s:18:"Pet-friendly Rooms";i:105;s:11:"Picnic Area";i:85;s:25:"Physical Distancing Rules";i:133;s:29:"Private Apartment in Building";i:134;s:16:"Private Bathroom";i:136;s:14:"Private Beach ";i:91;s:26:"Private Check-In/Check-Out";i:72;s:16:"Private Entrance";i:140;s:17:"Quiet Street View";i:144;s:10:"Restaurant";i:10;s:12:"Refrigerator";i:129;s:10:"River View";i:145;s:7:"Rooftop";i:4;s:12:"Room Service";i:65;s:4:"Safe";i:34;s:18:"Safety Deposit Box";i:147;s:5:"Sauna";i:73;s:8:"Sea view";i:74;s:12:"Seating Area";i:100;s:15:"Secured Parking";i:112;s:13:"Semi-detached";i:101;s:15:"Shared Bathroom";i:102;s:21:"Shared Lounge/TV Area";i:66;s:7:"Shampoo";i:106;s:9:"Shoeshine";i:68;s:6:"Shower";i:69;s:10:"Shower cap";i:31;s:15:"Shuttle Service";i:37;s:12:"Smoke Alarms";i:81;s:9:"Snack Bar";i:88;s:19:"Socket near the bed";i:50;s:4:"Sofa";i:16;s:24:"Spa & Wellness Amenities";i:59;s:18:"Special Diet Menus";i:154;s:66:"Staff follow all safety protocols as directed by local authorities";i:19;s:18:"Storage Available ";i:111;s:8:"Stovetop";i:97;s:14:"Street Parking";i:9;s:13:"Swimming Pool";i:86;s:16:"Tea/coffee maker";i:43;s:9:"Telephone";i:51;s:13:"Terrace/Patio";i:107;s:17:"Tile/Marble Floor";i:108;s:7:"Toaster";i:126;s:12:"Toilet Paper";i:139;s:10:"Toiletries";i:42;s:6:"Towels";i:143;s:2:"TV";i:75;s:10:"Trash Cans";i:117;s:33:"Upper Floors accessible by Stairs";i:104;s:13:"Valet Parking";i:151;s:19:"VIP Room Facilities";i:47;s:14:"Walk-in Shower";i:141;s:15:"Washing Machine";i:52;s:15:"Wardrobe/Closet";i:79;s:16:"Wedding services";i:82;s:6:"Window";i:135;s:12:"Wine Glasses";i:1;s:18:"Wheel Chair Access";}s:11:"icon_images";a:153:{i:5;s:0:"";i:60;s:0:"";i:138;s:0:"";i:55;s:0:"";i:122;s:0:"";i:30;s:0:"";i:123;s:0:"";i:142;s:0:"";i:61;s:0:"";i:46;s:0:"";i:48;s:0:"";i:45;s:0:"";i:39;s:0:"";i:148;s:0:"";i:84;s:0:"";i:35;s:0:"";i:13;s:0:"";i:25;s:0:"";i:27;s:0:"";i:56;s:0:"";i:57;s:0:"";i:14;s:0:"";i:6;s:0:"";i:32;s:0:"";i:116;s:0:"";i:20;s:0:"";i:22;s:0:"";i:21;s:0:"";i:78;s:0:"";i:132;s:0:"";i:90;s:0:"";i:118;s:0:"";i:64;s:0:"";i:11;s:0:"";i:36;s:0:"";i:114;s:0:"";i:17;s:0:"";i:40;s:0:"";i:96;s:0:"";i:92;s:0:"";i:49;s:0:"";i:113;s:0:"";i:44;s:0:"";i:155;s:0:"";i:8;s:0:"";i:152;s:0:"";i:26;s:0:"";i:3;s:0:"";i:2;s:0:"";i:77;s:0:"";i:93;s:0:"";i:130;s:0:"";i:71;s:0:"";i:115;s:0:"";i:83;s:0:"";i:131;s:0:"";i:124;s:0:"";i:7;s:0:"";i:149;s:0:"";i:157;s:0:"";i:24;s:0:"";i:58;s:0:"";i:103;s:0:"";i:125;s:0:"";i:62;s:0:"";i:137;s:0:"";i:99;s:0:"";i:38;s:0:"";i:41;s:0:"";i:128;s:0:"";i:156;s:0:"";i:33;s:0:"";i:94;s:0:"";i:150;s:0:"";i:15;s:0:"";i:67;s:0:"";i:146;s:0:"";i:76;s:0:"";i:29;s:0:"";i:63;s:0:"";i:89;s:0:"";i:18;s:0:"";i:54;s:0:"";i:120;s:0:"";i:53;s:0:"";i:109;s:0:"";i:119;s:0:"";i:28;s:0:"";i:70;s:0:"";i:98;s:0:"";i:121;s:0:"";i:153;s:0:"";i:95;s:0:"";i:80;s:0:"";i:23;s:0:"";i:105;s:0:"";i:85;s:0:"";i:133;s:0:"";i:134;s:0:"";i:136;s:0:"";i:91;s:0:"";i:72;s:0:"";i:140;s:0:"";i:144;s:0:"";i:10;s:0:"";i:129;s:0:"";i:145;s:0:"";i:4;s:0:"";i:65;s:0:"";i:34;s:0:"";i:147;s:0:"";i:73;s:0:"";i:74;s:0:"";i:100;s:0:"";i:112;s:0:"";i:101;s:0:"";i:102;s:0:"";i:66;s:0:"";i:106;s:0:"";i:68;s:0:"";i:69;s:0:"";i:31;s:0:"";i:37;s:0:"";i:81;s:0:"";i:88;s:0:"";i:50;s:0:"";i:16;s:0:"";i:59;s:0:"";i:154;s:0:"";i:19;s:0:"";i:111;s:0:"";i:97;s:0:"";i:9;s:0:"";i:86;s:0:"";i:43;s:0:"";i:51;s:0:"";i:107;s:0:"";i:108;s:0:"";i:126;s:0:"";i:139;s:0:"";i:42;s:0:"";i:143;s:0:"";i:75;s:0:"";i:117;s:0:"";i:104;s:0:"";i:151;s:0:"";i:47;s:0:"";i:141;s:0:"";i:52;s:0:"";i:79;s:0:"";i:82;s:0:"";i:135;s:0:"";i:1;s:0:"";}s:17:"how_display_items";s:7:"checked";s:14:"columns_number";s:1:"3";}
[search_options] =>
[group_id] => 0
)
我怎样才能从选项 =>“selection_items” 中获取结果。请指导我,我正在使用 wordpress。提前致谢
答:
1赞
LMc
5/29/2022
#1
WordPress 在存储在数据库中时序列化数组和 objext。
您需要取消序列化 的值。例如:options
unserialize($array['options']);
WordPress 还包括一个执行相同工作的maybe_unserialize函数,但它包含一个仅取消序列化已序列化数据的条件。
maybe_unserialize($array['options']);
取消序列化后,它将返回以下数组:options
array (
'selection_items' =>
array (
5 => '24-Hour Guest Reception',
60 => '24-Hour Security',
138 => 'Accessible Parking',
55 => 'Adapter',
122 => 'Additional Toilet',
30 => 'Air Conditioning',
123 => 'Allergy-free room',
142 => 'ATM On-Site',
61 => 'Babysitting/child services ',
46 => 'Balcony',
48 => 'Bathrobe',
45 => 'Bathtub',
39 => 'Bar/Lounge',
148 => 'Beachfront',
84 => 'Body Soap',
35 => 'Bridal Suite',
13 => 'Business Services',
25 => 'Cable/Satellite TV',
27 => 'CCTV',
56 => 'Cleaning Commodities',
57 => 'Clothes Rack',
14 => 'Complimentary Breakfast',
6 => 'Complimentary Toiletries',
32 => 'Concierge',
116 => 'Conditioner',
20 => 'Cribs & Cots for Children',
22 => 'Curated Experiences',
21 => 'Custom Offers',
78 => 'Designated Smoking Area',
132 => 'Detached',
90 => 'Dining Area',
118 => 'Drying Rack for Clothes',
64 => 'Electric Kettle',
11 => 'Electronics Chargers',
36 => 'Elevator Access',
114 => 'Entire Unit located on Ground Floor',
17 => 'Exercise Facilities (Gym)',
40 => 'Executive Lounge Access',
96 => 'Express Check in/Check Out',
92 => 'Family Rooms',
49 => 'Fan',
113 => 'Feather Pillow',
44 => 'Fire Extinguisher',
155 => 'First Aid Kit',
8 => 'Flexible Checkout',
152 => 'Food can be Delivered to Guest Accommodation',
26 => 'Free Early Check-in',
3 => 'Free Parking',
2 => 'Free WIFI',
77 => 'Fruits',
93 => 'Garden',
130 => 'Garden View',
71 => 'Gift shop',
115 => 'Grill',
83 => 'Hairdryer',
131 => 'Hand sanitizer in guest accommodation ',
124 => 'Hardwood or Parquet Floors',
7 => 'Healthy Breakfast',
149 => 'Hot Water',
157 => 'Heating',
24 => 'Housekeeping',
58 => 'Hypoallergenic pillow',
103 => 'Increased Accessibility',
125 => 'Inner Courtyard View',
62 => 'Interconnected room(s) available',
137 => 'Iron and Ironing Board',
99 => 'Ironing Service',
38 => 'Key Card Access',
41 => 'Kids Meals',
128 => 'Kid-friendly Buffet',
156 => 'Kid activities/ Kid Friendly',
33 => 'Kitchenette',
94 => 'Landmark View',
150 => 'Laptop Safe',
15 => 'Laundry Services',
67 => 'Linens',
146 => 'Lockers',
76 => 'Meeting/Banquet facilities',
29 => 'Microwave',
63 => 'Mountain View',
89 => 'Mosquito Net',
18 => 'Newspaper',
54 => 'No Pets Allowed',
120 => 'No Single-Use Plastics',
53 => 'No Smoking',
109 => 'Non-Feather Pillow',
119 => 'Non-Smoking Rooms Available',
28 => 'On-site Restaurant',
70 => 'Outdoor furniture',
98 => 'Outdoor Dining Area',
121 => 'Oven',
153 => 'Outdoor Fireplace',
95 => 'Packed Lunches',
80 => 'Pants Press',
23 => 'Pet-friendly Rooms',
105 => 'Picnic Area',
85 => 'Physical Distancing Rules',
133 => 'Private Apartment in Building',
134 => 'Private Bathroom',
136 => 'Private Beach ',
91 => 'Private Check-In/Check-Out',
72 => 'Private Entrance',
140 => 'Quiet Street View',
144 => 'Restaurant',
10 => 'Refrigerator',
129 => 'River View',
145 => 'Rooftop',
4 => 'Room Service',
65 => 'Safe',
34 => 'Safety Deposit Box',
147 => 'Sauna',
73 => 'Sea view',
74 => 'Seating Area',
100 => 'Secured Parking',
112 => 'Semi-detached',
101 => 'Shared Bathroom',
102 => 'Shared Lounge/TV Area',
66 => 'Shampoo',
106 => 'Shoeshine',
68 => 'Shower',
69 => 'Shower cap',
31 => 'Shuttle Service',
37 => 'Smoke Alarms',
81 => 'Snack Bar',
88 => 'Socket near the bed',
50 => 'Sofa',
16 => 'Spa & Wellness Amenities',
59 => 'Special Diet Menus',
154 => 'Staff follow all safety protocols as directed by local authorities',
19 => 'Storage Available ',
111 => 'Stovetop',
97 => 'Street Parking',
9 => 'Swimming Pool',
86 => 'Tea/coffee maker',
43 => 'Telephone',
51 => 'Terrace/Patio',
107 => 'Tile/Marble Floor',
108 => 'Toaster',
126 => 'Toilet Paper',
139 => 'Toiletries',
42 => 'Towels',
143 => 'TV',
75 => 'Trash Cans',
117 => 'Upper Floors accessible by Stairs',
104 => 'Valet Parking',
151 => 'VIP Room Facilities',
47 => 'Walk-in Shower',
141 => 'Washing Machine',
52 => 'Wardrobe/Closet',
79 => 'Wedding services',
82 => 'Window',
135 => 'Wine Glasses',
1 => 'Wheel Chair Access',
),
'icon_images' =>
array (
5 => '',
60 => '',
138 => '',
55 => '',
122 => '',
30 => '',
123 => '',
142 => '',
61 => '',
46 => '',
48 => '',
45 => '',
39 => '',
148 => '',
84 => '',
35 => '',
13 => '',
25 => '',
27 => '',
56 => '',
57 => '',
14 => '',
6 => '',
32 => '',
116 => '',
20 => '',
22 => '',
21 => '',
78 => '',
132 => '',
90 => '',
118 => '',
64 => '',
11 => '',
36 => '',
114 => '',
17 => '',
40 => '',
96 => '',
92 => '',
49 => '',
113 => '',
44 => '',
155 => '',
8 => '',
152 => '',
26 => '',
3 => '',
2 => '',
77 => '',
93 => '',
130 => '',
71 => '',
115 => '',
83 => '',
131 => '',
124 => '',
7 => '',
149 => '',
157 => '',
24 => '',
58 => '',
103 => '',
125 => '',
62 => '',
137 => '',
99 => '',
38 => '',
41 => '',
128 => '',
156 => '',
33 => '',
94 => '',
150 => '',
15 => '',
67 => '',
146 => '',
76 => '',
29 => '',
63 => '',
89 => '',
18 => '',
54 => '',
120 => '',
53 => '',
109 => '',
119 => '',
28 => '',
70 => '',
98 => '',
121 => '',
153 => '',
95 => '',
80 => '',
23 => '',
105 => '',
85 => '',
133 => '',
134 => '',
136 => '',
91 => '',
72 => '',
140 => '',
144 => '',
10 => '',
129 => '',
145 => '',
4 => '',
65 => '',
34 => '',
147 => '',
73 => '',
74 => '',
100 => '',
112 => '',
101 => '',
102 => '',
66 => '',
106 => '',
68 => '',
69 => '',
31 => '',
37 => '',
81 => '',
88 => '',
50 => '',
16 => '',
59 => '',
154 => '',
19 => '',
111 => '',
97 => '',
9 => '',
86 => '',
43 => '',
51 => '',
107 => '',
108 => '',
126 => '',
139 => '',
42 => '',
143 => '',
75 => '',
117 => '',
104 => '',
151 => '',
47 => '',
141 => '',
52 => '',
79 => '',
82 => '',
135 => '',
1 => '',
),
'how_display_items' => 'checked',
'columns_number' => '3',
)
评论
0赞
Md Arif
5/29/2022
感谢您的重播,实际上我正在尝试从数据库中获取数据。当我尝试使用您的代码时,我遇到了错误,请解决我的查询 $retrieve_data = $wpdb->get_results( “SELECT * FROM $table_name” );foreach ($retrieve_data as $key => $myvalue) { $properties = get_object_vars($myvalue); print_r($properties); }
0赞
LMc
5/29/2022
请您更新您的问题。是 print_r($properties);从您的问题中返回数组?
评论