首页 \ 问答 \ 如何在php中查找非空值并显示if条件[复制](How to find the not null values in php and display in if condition [duplicate])

如何在php中查找非空值并显示if条件[复制](How to find the not null values in php and display in if condition [duplicate])

这个问题在这里已经有了答案:

在这里我有一个数组,我想找到不空值和显示在前端,假设在这个数组中的所有键值在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
更新时间:2022-05-11 11:05

最满意答案

弄清楚了。 从客户端,您可以通过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 :)

相关问答

更多
  • 是的,“实际”用例需要编写服务器端代码。 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 ...
  • Firebase SDK尝试在特定位置注册服务工作人员。 位置是+ /firebase-messaging-sw.js。 有两种选择: 1.)让+ / firebase-messaging-sw.js在浏览器中工作(即确保它返回有效的响应),然后再次尝试使用SDK(如果浏览器可以访问该文件,它应该可以工作)。 2.)使用useServiceworker()方法传递一个自定义服务工作者。 这仍然需要您有一个有效的服务工作者URL。 The Fireba ...
  • 首先要说的是这在一定程度上取决于平台。 我对铬的理解是: 在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 ...
  • 看来这最近确实发生了变化 。 它似乎也会保持当前的行为 - 请参阅服务人员规格库中的讨论 。 这两个讨论都引用这个规范作为政策的基础。 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 ...
  • 弄清楚了。 从客户端,您可以通过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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)