如何在php中查找非空值并显示if条件[复制](How to find the not null values in php and display in if condition [duplicate])
这个问题在这里已经有了答案:
- 如何检查数组是否包含空元素? 5个答案
在这里我有一个数组,我想找到不空值和显示在前端,假设在这个数组中的所有键值在null意味着我想显示所有值为null,假设任何一个键不为null意味着我想显示什么是价值
<?php $array = array('a' => '','b' => 'Kani' , 'c' => '', 'd' => 'Raja'); if (in_array(null, $array)) { echo "There are null values."; }else{ echo "Not Null"; } ?>
这里关键a和d不为空,所以我想要像Kani和Raja这样的关键值
This question already has an answer here:
Here i have one array in that array i want to find not null values and display in frond end ,suppose in this array all key values in null means i want to display all values are null,suppose any one of the key is not null means i want to display what is that value
<?php $array = array('a' => '','b' => 'Kani' , 'c' => '', 'd' => 'Raja'); if (in_array(null, $array)) { echo "There are null values."; }else{ echo "Not Null"; } ?>
Here key a and d is not null so i want take this key value like Kani and Raja
原文:https://stackoverflow.com/questions/42256037
最满意答案
弄清楚了。 从客户端,您可以通过ServiceWorkerRegistration访问服务工作者,并有一种方法可以获取SW注册的所有通知。
请参阅: ServiceWorkerRegistration.getNotifications()
还有另一种方式,但涉及更多的代码:发送一条消息(使用
navigator.serviceWorker.controller.postMessage
)给服务工作者,获取通知(self.registration.getNotifications()
),然后从那里取消它们。 这就是我解决问题的方法,然后发现了第一个解决方案。 但是,如果您还需要服务人员执行其他操作,这可能仍然很有用。 另外,在创建它的同一个地方取消通知是很好的:)Figured it out. From the client you have access to the service worker via ServiceWorkerRegistration and that has a method to get all notifications the SW registered.
See: ServiceWorkerRegistration.getNotifications()
There is another way but it involves more code: send a message (using
navigator.serviceWorker.controller.postMessage
) to the service worker, get the notifications (self.registration.getNotifications()
) and then cancel them from there. This is how I solved the question and then found out about the first solution. This may still be useful if you need to have the service worker do other things, too, though. Also, it's kind of nice to cancel the notification in the same place it was created :)
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
如何实现服务工作者?(How to implement service worker?)[2023-01-15]
是的,“实际”用例需要编写服务器端代码。 curl命令只是对功能的一次性测试。 https://github.com/gauntface/simple-push-demo是一个很好的服务器端起点,假设是一个Python App Engine后端。 Yes, writing server-side code is required for "real" use cases. The curl command is just meant as a one-off test of the functionalit ... -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
在使用GWT时找不到Firebase服务工作人员(404错误)(Firebase Service worker not found while using GWT (404 Error))[2022-03-28]
Firebase SDK尝试在特定位置注册服务工作人员。 位置是+ /firebase-messaging-sw.js。 有两种选择: 1.)让+ / firebase-messaging-sw.js在浏览器中工作(即确保它返回有效的响应),然后再次尝试使用SDK(如果浏览器可以访问该文件,它应该可以工作)。 2.)使用useServiceworker()方法传递一个自定义服务工作者。 这仍然需要您有一个有效的服务工作者URL。 The Fireba ... -
即使浏览器关闭,服务人员是否仍然在后台运行?(Does service worker runs on background even if browser is closed?)[2022-11-24]
首先要说的是这在一定程度上取决于平台。 我对铬的理解是: 在Windows和Mac OS X等桌面平台上,浏览器需要运行一些后台进程才能运行。 在Mac OS X上,这很容易检测到,因为浏览器可能没有打开窗口,但浏览器仍然有下面的发光点。 在移动平台上,倾听事件并以有效方式处理事件更容易,因此在这些情况下,平台可以唤醒浏览器,然后处理任何相应的事件。 以上内容适用于任何服务人员的API。 在桌面上:如果浏览器完全关闭,那么服务人员将无法运行,也不会派发任何事件(即无推送或后台同步事件) 在移动设备上:事件仍 ... -
处理对基于Service Worker的通知的点击的正确位置在Service Worker中。 您需要将您的侦听器 - 具有self.addEventListener('notificationclick', ...)移至您的Service Worker代码。 请注意,您没有window访问权限。 要导航到URL,您需要改为使用clients.openWindow 。 因此,您的应用程序端代码将只有reg.showNotification调用,并且Service Worker中的您的处理程序将如下所示: s ...
-
在https内部框架中注册服务工作人员时的DOMException(DOMException when registering service worker inside an https iframe)[2023-10-14]
看来这最近确实发生了变化 。 它似乎也会保持当前的行为 - 请参阅服务人员规格库中的讨论 。 这两个讨论都引用这个规范作为政策的基础。 It appears that this did change recently. It also appears that the current behaviour will now be maintained - see this discussion at the service worker spec repository. Both of those discu ... -
取消服务工作人员创建的浏览器通知(Cancel a notification from browser that was created by a service worker)[2024-05-20]
弄清楚了。 从客户端,您可以通过ServiceWorkerRegistration访问服务工作者,并有一种方法可以获取SW注册的所有通知。 请参阅: ServiceWorkerRegistration.getNotifications() 还有另一种方式,但涉及更多的代码:发送一条消息(使用navigator.serviceWorker.controller.postMessage )给服务工作者,获取通知( self.registration.getNotifications() ),然后从那里取消它们。 ... -
你是对的。 永远不要缓存service-worker.js。 为了避免尝试在没有连通性的情况下注册导致的错误,只需从window.navigator.onLine中检查连接状态,并在脱机时跳过调用注册表。 如果需要,您可以监听网络状态更改并在稍后的时间点呼叫注册。 You're correct. Never cache service-worker.js. To avoid the error that comes from trying to register without connectivity s ...
-
https://www.w3.org/TR/2015/NOTE-task-scheduler-20150723/包含以下注释: 该规范作为工作组说明重新发布,表明它没有作为建议书跟踪文件进一步发展。 我不相信有任何期望该文档中描述的API将被添加到浏览器中。 根据您要查看的内容, Budget API , Background Fetch API和Background Sync API的某些组合可能会满足您的使用案例,但它们并非全部受到广泛支持。 https://www.w3.org/TR/2015/NOT ...