在下面的场景中,如何用适当的字符替换各种数组元素中的HTML实体


How to replace the HTML entities present with proper characters in various array elements in following scenario?

我有一个名为$data的大型关联数组,如下所示:

Array
(
    [0] => Array
        (
            [feed_id] => 1191
            [app_id] => 0
            [privacy] => 0
            [privacy_comment] => 0
            [type_id] => link
            [user_id] => 244
            [parent_user_id] => 0
            [item_id] => 75
            [time_stamp] => 1423140990
            [feed_reference] => 0
            [parent_feed_id] => 0
            [parent_module_id] => 
            [time_update] => 1423140990
            [app_title] => 
            [profile_page_id] => 0
            [user_server_id] => 0
            [user_name] => profile-244
            [full_name] => Campusknot .
            [gender] => 0
            [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
            [is_invisible] => 0
            [user_group_id] => 7
            [language_id] => 
            [feed_time_stamp] => 1423140990
            [can_post_comment] => 1
            [feed_title] => Yahoo
            [feed_status] => my WS link post
            [feed_link_comment] => http://54.174.50.242/profile-244/link-id_75/
            [feed_link] => http://54.174.50.242/profile-244/link-id_75/
            [feed_link_actual] => http://yahoo.com
            [feed_content] => By David Gaffen and Sebastien Malo MOUNT PLEASANT, N.Y. (Reuters) - Six people were killed and more than a dozen injured when a crowded New York commuter train struck a car stalled on the tracks near s
            [total_comment] => 0
            [feed_total_like] => 0
            [feed_is_liked] => 
            [feed_icon] => http://54.174.50.242/theme/frontend/foxplus/style/default/image/feed/link.png
            [enable_like] => 1
            [comment_type_id] => link
            [like_type_id] => link
            [feed_title_extra] => yahoo.com
            [feed_title_extra_link] => http://yahoo.com
            [is_custom_app] => 
            [app_image_path] => 
            [custom_data_cache] => Array
                (
                    [link_id] => 75
                    [user_id] => 244
                    [module_id] => 
                    [item_id] => 0
                    [parent_user_id] => 
                    [is_custom] => 0
                    [link] => http://yahoo.com
                    [image] => https://s.yimg.com/dh/ap/default/130909/y_200_a.png
                    [title] => Yahoo
                    [description] => By David Gaffen and Sebastien Malo MOUNT PLEASANT, N.Y. (Reuters) - Six people were killed and more than a dozen injured when a crowded New York commuter train struck a car stalled on the tracks near s
                    [status_info] => my WS link post
                    [privacy] => 0
                    [privacy_comment] => 0
                    [time_stamp] => 1423140990
                    [has_embed] => 0
                    [total_comment] => 0
                    [total_like] => 0
                    [total_dislike] => 0
                    [is_liked] => 
                    [app_id] => 
                    [app_image_path] => 
                    [parent_profile_page_id] => 
                    [user_parent_server_id] => 
                    [parent_user_name] => 
                    [parent_full_name] => 
                    [parent_gender] => 
                    [parent_user_image] => 
                    [parent_is_invisible] => 
                    [parent_user_group_id] => 
                    [parent_language_id] => 
                )
            [feed_image] => <img src="https://s.yimg.com/dh/ap/default/130909/y_200_a.png" alt="" style="max-width:120px; max-height:90px;" />
            [feed_info] => posted a link.
            [likes] => Array
                (
                )
            [marks] => Array
                (
                )
            [bShowEnterCommentBlock] => 
            [feed_month_year] => 02_2015
            [feed_like_phrase] => 
            [user_group_name] => faculty
        )
    [1] => Array
        (
            [feed_id] => 1190
            [app_id] => 0
            [privacy] => 0
            [privacy_comment] => 0
            [type_id] => codesnippet
            [user_id] => 244
            [parent_user_id] => 0
            [item_id] => 57
            [time_stamp] => 1423138957
            [feed_reference] => 0
            [parent_feed_id] => 0
            [parent_module_id] => 
            [time_update] => 1423138957
            [app_title] => 
            [profile_page_id] => 0
            [user_server_id] => 0
            [user_name] => profile-244
            [full_name] => Campusknot .
            [gender] => 0
            [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
            [is_invisible] => 0
            [user_group_id] => 7
            [language_id] => 
            [feed_time_stamp] => 1423138957
            [can_post_comment] => 1
            [feed_title] => 
            [feed_info] => posted a code-snippet.
            [feed_link] => 
            [total_comment] => 0
            [feed_total_like] => 1
            [feed_is_liked] => 553
            [feed_icon] => http://54.174.50.242/theme/frontend/foxplus/style/default/image/module/poll.png
            [enable_like] => 1
            [comment_type_id] => codesnippet
            [like_type_id] => codesnippet
            [feed_custom_html] => 
<pre class="prettyprint linenums ">
&lt;html&gt;
                                   &lt;body&gt;hello world123 new&lt;/body&gt;
                          &lt;/html&gt;
</pre>
            [feed_status] => this is my sample code
            [custom_data_cache] => Array
                (
                    [code_id] => 57
                    [module_id] => null
                    [item_id] => 0
                    [user_id] => 244
                    [view_id] => 0
                    [codesnippet] => &lt;html&gt;
                                   &lt;body&gt;hello world123 new&lt;/body&gt;
                          &lt;/html&gt;
                    [privacy] => 0
                    [privacy_comment] => 0
                    [time_stamp] => 1423138957
                    [total_comment] => 0
                    [total_like] => 1
                    [total_dislike] => 0
                    [total_view] => 0
                    [server_id] => 0
                    [text] => this is my sample code
                    [is_liked] => 553
                    [profile_page_id] => 0
                    [user_server_id] => 0
                    [user_name] => profile-244
                    [full_name] => Campusknot .
                    [gender] => 0
                    [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
                    [is_invisible] => 0
                    [user_group_id] => 7
                    [language_id] => 
                )
            [more_feed_rows] => Array
                (
                    [0] => Array
                        (
                            [feed_id] => 1189
                            [app_id] => 0
                            [privacy] => 0
                            [privacy_comment] => 0
                            [type_id] => codesnippet
                            [user_id] => 244
                            [parent_user_id] => 0
                            [item_id] => 56
                            [time_stamp] => 1423138912
                            [feed_reference] => 0
                            [parent_feed_id] => 0
                            [parent_module_id] => 
                            [time_update] => 1423138912
                            [app_title] => 
                            [profile_page_id] => 0
                            [user_server_id] => 0
                            [user_name] => profile-244
                            [full_name] => Campusknot .
                            [gender] => 0
                            [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
                            [is_invisible] => 0
                            [user_group_id] => 7
                            [language_id] => 
                            [can_post_comment] => 1
                            [feed_title] => 
                            [feed_info] => posted a code-snippet.
                            [feed_link] => 
                            [total_comment] => 0
                            [feed_total_like] => 0
                            [feed_is_liked] => 0
                            [feed_icon] => http://54.174.50.242/theme/frontend/foxplus/style/default/image/module/poll.png
                            [enable_like] => 1
                            [comment_type_id] => codesnippet
                            [like_type_id] => codesnippet
                            [feed_custom_html] => 
<pre class="prettyprint linenums ">
&lt;html&gt;
                                   &lt;body&gt;hello world123&lt;/body&gt;
                          &lt;/html&gt;
</pre>
                            [feed_status] => this is my sample code
                            [custom_data_cache] => Array
                                (
                                    [code_id] => 56
                                    [module_id] => null
                                    [item_id] => 0
                                    [user_id] => 244
                                    [view_id] => 0
                                    [codesnippet] => &lt;html&gt;
                                   &lt;body&gt;hello world123&lt;/body&gt;
                          &lt;/html&gt;
                                    [privacy] => 0
                                    [privacy_comment] => 0
                                    [time_stamp] => 1423138912
                                    [total_comment] => 0
                                    [total_like] => 0
                                    [total_dislike] => 0
                                    [total_view] => 0
                                    [server_id] => 0
                                    [text] => this is my sample code
                                    [is_liked] => 
                                    [profile_page_id] => 0
                                    [user_server_id] => 0
                                    [user_name] => profile-244
                                    [full_name] => Campusknot .
                                    [gender] => 0
                                    [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
                                    [is_invisible] => 0
                                    [user_group_id] => 7
                                    [language_id] => 
                                )
                            [likes] => Array
                                (
                                )
                            [marks] => Array
                                (
                                )
                            [bShowEnterCommentBlock] => 
                            [user_group_name] => faculty
                        )
                    [1] => Array
                        (
                            [feed_id] => 1188
                            [app_id] => 0
                            [privacy] => 0
                            [privacy_comment] => 0
                            [type_id] => codesnippet
                            [user_id] => 244
                            [parent_user_id] => 0
                            [item_id] => 55
                            [time_stamp] => 1423138759
                            [feed_reference] => 0
                            [parent_feed_id] => 0
                            [parent_module_id] => 
                            [time_update] => 1423138759
                            [app_title] => 
                            [profile_page_id] => 0
                            [user_server_id] => 0
                            [user_name] => profile-244
                            [full_name] => Campusknot .
                            [gender] => 0
                            [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
                            [is_invisible] => 0
                            [user_group_id] => 7
                            [language_id] => 
                            [can_post_comment] => 1
                            [feed_title] => 
                            [feed_info] => posted a code-snippet.
                            [feed_link] => 
                            [total_comment] => 0
                            [feed_total_like] => 0
                            [feed_is_liked] => 0
                            [feed_icon] => http://54.174.50.242/theme/frontend/foxplus/style/default/image/module/poll.png
                            [enable_like] => 1
                            [comment_type_id] => codesnippet
                            [like_type_id] => codesnippet
                            [feed_custom_html] => 
<pre class="prettyprint linenums ">
&lt;html&gt;&lt;body&gt;hello world&lt;/body&gt;&lt;/html&gt;
</pre>
                            [feed_status] => this is my sample code
                            [custom_data_cache] => Array
                                (
                                    [code_id] => 55
                                    [module_id] => null
                                    [item_id] => 0
                                    [user_id] => 244
                                    [view_id] => 0
                                    [codesnippet] => &lt;html&gt;&lt;body&gt;hello world&lt;/body&gt;&lt;/html&gt;
                                    [privacy] => 0
                                    [privacy_comment] => 0
                                    [time_stamp] => 1423138759
                                    [total_comment] => 0
                                    [total_like] => 0
                                    [total_dislike] => 0
                                    [total_view] => 0
                                    [server_id] => 0
                                    [text] => this is my sample code
                                    [is_liked] => 
                                    [profile_page_id] => 0
                                    [user_server_id] => 0
                                    [user_name] => profile-244
                                    [full_name] => Campusknot .
                                    [gender] => 0
                                    [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
                                    [is_invisible] => 0
                                    [user_group_id] => 7
                                    [language_id] => 
                                )
                            [likes] => Array
                                (
                                )
                            [marks] => Array
                                (
                                )
                            [bShowEnterCommentBlock] => 
                            [user_group_name] => faculty
                        )
                )
            [likes] => Array
                (
                    [244] => Array
                        (
                            [like_id] => 553
                            [type_id] => codesnippet
                            [item_id] => 57
                            [user_id] => 244
                            [time_stamp] => 1423199034
                            [profile_page_id] => 0
                            [user_server_id] => 0
                            [user_name] => profile-244
                            [full_name] => Campusknot .
                            [gender] => 0
                            [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
                            [is_invisible] => 0
                            [user_group_id] => 7
                            [language_id] => 
                            [action_time_stamp] => 
                        )
                )
            [marks] => Array
                (
                )
            [bShowEnterCommentBlock] => 1
            [feed_month_year] => 02_2015
            [feed_like_phrase] => You&nbsp;like this.
            [user_group_name] => faculty
        )
    [2] => Array
        (
            [feed_id] => 1184
            [app_id] => 0
            [privacy] => 0
            [privacy_comment] => 0
            [type_id] => user_status
            [user_id] => 244
            [parent_user_id] => 0
            [item_id] => 61
            [time_stamp] => 1423117253
            [feed_reference] => 0
            [parent_feed_id] => 0
            [parent_module_id] => 
            [time_update] => 1423117253
            [app_title] => 
            [profile_page_id] => 0
            [user_server_id] => 0
            [user_name] => profile-244
            [full_name] => Campusknot .
            [gender] => 0
            [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
            [is_invisible] => 0
            [user_group_id] => 7
            [language_id] => 
            [report_module] => user_status
            [report_phrase] => Report this entry
            [force_report] => 1
            [feed_time_stamp] => 1423117253
            [can_post_comment] => 1
            [feed_status] => My new post for test
            [feed_title] => 
            [feed_link] => http://54.174.50.242/profile-244/status-id_61/
            [total_comment] => 0
            [feed_total_like] => 1
            [feed_is_liked] => 544
            [feed_icon] => http://54.174.50.242/theme/frontend/foxplus/style/default/image/misc/application_add.png
            [enable_like] => 1
            [comment_type_id] => user_status
            [like_type_id] => user_status
            [likes] => Array
                (
                    [244] => Array
                        (
                            [like_id] => 544
                            [type_id] => user_status
                            [item_id] => 61
                            [user_id] => 244
                            [time_stamp] => 1423121845
                            [profile_page_id] => 0
                            [user_server_id] => 0
                            [user_name] => profile-244
                            [full_name] => Campusknot .
                            [gender] => 0
                            [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
                            [is_invisible] => 0
                            [user_group_id] => 7
                            [language_id] => 
                            [action_time_stamp] => 
                        )
                )
            [marks] => Array
                (
                )
            [bShowEnterCommentBlock] => 1
            [feed_month_year] => 02_2015
            [feed_like_phrase] => You&nbsp;like this.
            [user_group_name] => faculty
        )
    [4] => Array
        (
            [feed_id] => 1174
            [app_id] => 0
            [privacy] => 0
            [privacy_comment] => 0
            [type_id] => user_status
            [user_id] => 244
            [parent_user_id] => 0
            [item_id] => 50
            [time_stamp] => 1420632285
            [feed_reference] => 0
            [parent_feed_id] => 0
            [parent_module_id] => 
            [time_update] => 1420824693
            [app_title] => 
            [profile_page_id] => 0
            [user_server_id] => 0
            [user_name] => profile-244
            [full_name] => Campusknot .
            [gender] => 0
            [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
            [is_invisible] => 0
            [user_group_id] => 7
            [language_id] => 
            [report_module] => user_status
            [report_phrase] => Report this entry
            [force_report] => 1
            [feed_time_stamp] => 1420632285
            [can_post_comment] => 1
            [feed_status] => Share what&#039;s going on...
            [feed_title] => 
            [feed_link] => http://54.174.50.242/profile-244/status-id_50/
            [total_comment] => 2
            [feed_total_like] => 2
            [feed_is_liked] => 540
            [feed_icon] => http://54.174.50.242/theme/frontend/foxplus/style/default/image/misc/application_add.png
            [enable_like] => 1
            [comment_type_id] => user_status
            [like_type_id] => user_status
            [likes] => Array
                (
                    [244] => Array
                        (
                            [like_id] => 540
                            [type_id] => user_status
                            [item_id] => 50
                            [user_id] => 244
                            [time_stamp] => 1423055705
                            [profile_page_id] => 0
                            [user_server_id] => 0
                            [user_name] => profile-244
                            [full_name] => Campusknot .
                            [gender] => 0
                            [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
                            [is_invisible] => 0
                            [user_group_id] => 7
                            [language_id] => 
                            [action_time_stamp] => 
                        )
                    [1] => Array
                        (
                            [like_id] => 462
                            [type_id] => user_status
                            [item_id] => 50
                            [user_id] => 1
                            [time_stamp] => 1421021769
                            [profile_page_id] => 0
                            [user_server_id] => 1
                            [user_name] => admin
                            [full_name] => admin
                            [gender] => 1
                            [user_image] => 2014/11/d424bc46529b9f8d764b6b485e6c8716%s.png
                            [is_invisible] => 0
                            [user_group_id] => 1
                            [language_id] => 
                            [action_time_stamp] => 
                        )
                )
            [comments] => Array
                (
                    [0] => Array
                        (
                            [is_liked] => 
                            [comment_id] => 159
                            [parent_id] => 0
                            [type_id] => user_status
                            [item_id] => 50
                            [user_id] => 244
                            [owner_user_id] => 244
                            [time_stamp] => 1420792308
                            [update_time] => 0
                            [update_user] => 
                            [rating] => 
                            [ip_address] => 182.72.250.166
                            [author] => 1174
                            [author_email] => 
                            [author_url] => 
                            [view_id] => 0
                            [child_total] => 0
                            [total_like] => 0
                            [total_dislike] => 0
                            [text] => How are you all?
                            [profile_page_id] => 0
                            [user_server_id] => 0
                            [user_name] => profile-244
                            [full_name] => Campusknot .
                            [gender] => 0
[user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
                            [is_invisible] => 0
                            [user_group_id] => 7
                            [language_id] => 
                            [post_convert_time] => January 9, 2015
                        )
                    [1] => Array
                        (
                            [is_liked] => 473
                            [comment_id] => 160
                            [parent_id] => 0
                            [type_id] => user_status
                            [item_id] => 50
                            [user_id] => 244
                            [owner_user_id] => 244
                            [time_stamp] => 1420824693
                            [update_time] => 0
                            [update_user] => 
                            [rating] => 
                            [ip_address] => 117.200.210.100
                            [author] => 1174
                            [author_email] => 
                            [author_url] => 
                            [view_id] => 0
                            [child_total] => 0
                            [total_like] => 2
                            [total_dislike] => 0
                            [text] => fsfsd
                            [profile_page_id] => 0
                            [user_server_id] => 0
                            [user_name] => profile-244
                            [full_name] => Campusknot .
                            [gender] => 0
                            [user_image] => 2015/02/ade52764529ccd469bbddf98aa62712c%s.jpg
                            [is_invisible] => 0
                            [user_group_id] => 7
                            [language_id] => 
                            [post_convert_time] => January 10, 2015
                        )
                )
            [marks] => Array
                (
                )
            [bShowEnterCommentBlock] => 1
            [feed_month_year] => 01_2015
            [feed_like_phrase] => You<span class="user_profile_link_span" id="js_user_name_link_admin"><a href="http://54.174.50.242/admin/">admin</a></span>&nbsp;like this.
            [more_feed_rows] => Array
                (
                    [0] => Array
                        (
                            [user_group_name] => faculty
                        )
                )
            [user_group_name] => faculty
        )
)

由于上面的数组是动态生成的,所以它的大小可能会更大。所以我的问题是,我想删除出现在各种数组键值中的HTML实体。

我怎样才能以高效的方式做到这一点?请给我建议解决办法。

谢谢。

@PHPNut你可以这样做。

$my_arr = array('key'=>'hiiiiii<br>');
function remove(&$item, $key)
{
    $item = strip_tags($item);
}
array_walk_recursive($my_arr, 'remove');
print_r($my_arr);