How to use PHP to determine if the ID value in a div is empty

Source: Internet
Author: User
    1. How to use PHP to determine whether the ID value of the loop div is empty, if it is not empty, the div layer is displayed normally, if empty then hidden?

The following code is my code.

Do not know whether to use PHP to determine the efficiency of high or the use of JQ judgement efficiency.

To try without API key: $video _list = Json_decode (file_get_contents (")); $video _list = Json_decode (file_get_contents ( ' https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId= '. $channelId. ' &maxresults= '. $maxResults. ' &key= '. $API _key. '); foreach ($video _list->items as $item) {//embed Video if (isset ($item->id->videoid)) {echo ' Id->videoi D. ' "class=" xl12 xs6 xm4 xb3 video-box "> Id->videoid. '" target= "_blank" title= "'. $item->snippet->title. ' " >id->videoid. ' class= ' radius img-responsive ' alt= '. $item->snippet->title. ' " >

Id->videoid. ' " > '. $item->snippet->title. '

'; }//embed Playlist Else if (Isset ($item->id->playlistid)) {echo ' id->videoid. ' "cl ass= "xl12 xs6 xm4 xb3 video-box" > id->videoid "target=" _blank "title=". $item->snippet->title. ' " >id->videoid. ' class= ' radius img-responsive ' alt= '. $item->snippet->title. ' " >

Id->videoid. ' " > '. $item->snippet->title. '

'; }}

The following code is the video list of the parent div,id= "here to get the video key ID number,"
Id->videoid. ' class= ' xl12 xs6 xm4 xb3 Video-box ">

Id->videoid. ' class= ' xl12 xs6 xm4 xb3 Video-box ">
Internal HTML

Because it is to take the video of foreign sites, so sometimes not to get the video key ID, so it cannot be loaded.
How to modify the above code implementation, Judge Id->videoid. ' "
Is the id= "value" empty, and if it is empty, the empty video message is hidden with the Display:none property of style or class?

Reply content:

    1. How to use PHP to determine whether the ID value of the loop div is empty, if it is not empty, the div layer is displayed normally, if empty then hidden?

The following code is my code.

Do not know whether to use PHP to determine the efficiency of high or the use of JQ judgement efficiency.

To try without API key: $video _list = Json_decode (file_get_contents (")); $video _list = Json_decode (file_get_contents ( ' https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId= '. $channelId. ' &maxresults= '. $maxResults. ' &key= '. $API _key. '); foreach ($video _list->items as $item) {//embed Video if (isset ($item->id->videoid)) {echo ' Id->videoi D. ' "class=" xl12 xs6 xm4 xb3 video-box "> Id->videoid. '" target= "_blank" title= "'. $item->snippet->title. ' " >id->videoid. ' class= ' radius img-responsive ' alt= '. $item->snippet->title. ' " >

Id->videoid. ' " > '. $item->snippet->title. '

'; }//embed Playlist Else if (Isset ($item->id->playlistid)) {echo ' id->videoid. ' "cl ass= "xl12 xs6 xm4 xb3 video-box" > id->videoid "target=" _blank "title=". $item->snippet->title. ' " >id->videoid. ' class= ' radius img-responsive ' alt= '. $item->snippet->title. ' " >

Id->videoid. ' " > '. $item->snippet->title. '

'; }}

The following code is the video list of the parent div,id= "here to get the video key ID number,"
Id->videoid. ' class= ' xl12 xs6 xm4 xb3 Video-box ">

Id->videoid. ' class= ' xl12 xs6 xm4 xb3 Video-box ">
Internal HTML

Because it is to take the video of foreign sites, so sometimes not to get the video key ID, so it cannot be loaded.
How to modify the above code implementation, Judge Id->videoid. ' "
Is the id= "value" empty, and if it is empty, the empty video message is hidden with the Display:none property of style or class?

Directly with CSS

DIV[id=""] { display: none; }

WEB--JS. PHP, SERVER.

This API gets JSON. Isn't the data complete? Where is the ID for the data to be empty? That's weird.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.