is-empty

How do I hide several lines if php variable is empty?

依然范特西╮ 提交于 2019-12-23 18:50:09
问题 As a learner in PHP, I'm struggling to hide from displaying several lines, if a chosen variable is empty. I can get this to work on a basic level, but am lost when the content to be hidden gets more complicated. The concept I am aiming at is this: <?php if (isset($g1)) { ?> ((This part should not display if variable $g1 is empty)) <?php } ?> My code looks like this: <?php if (isset($g1)) { ?> <a href="img/g1.png" class="lightbox" rel="tooltip" data-original-title="<?php print $g1; ?>" data

Laravel Check Empty Array

ⅰ亾dé卋堺 提交于 2019-12-23 15:09:35
问题 I still have trouble with checking if an array is empty or not in laravel. This is my view: @foreach($restaurantmenue as $daily) @if(empty($daily->articles)) no article @else @foreach($daily->articles as $menue) <a class="card-link" href="#"> <h4 class="title">{{$menue->title}} </h4> </a> @endforeach @endif @endforeach {{dd($daily->articles)}} When I check my views (One with an Article and the other without an article) I get this output: The View with an existing article shows: Collection {

Excel Sum if not Null String

自闭症网瘾萝莉.ら 提交于 2019-12-23 02:33:11
问题 I would like to sum all cells in column B that corresponds to cells in column A which are not empty. However, in Excel, the term "not empty" is a bit ambigious: if a cell contains a formula, but the result is a null string, i.e. =IF(1=0,1,"") , it is considered not empty, even though the result is essentially nothing. However, I want to exclude such cells. The obvious thing to try first is =SUMIF(A:A,"<>",B:B) But this does not work, because the operator <> only says a cell is empty if it is

Why does an empty dataframe fail an is.null() test?

落花浮王杯 提交于 2019-12-20 10:25:04
问题 please excuse me if my question is quite basic. I created an empty data frame by df <- data.frame() and obviously the data frame is NULL (empty). when I try to check if the data frame is empty by is.null(df) , the result comes FALSE. Is there any difference between NULL and empty in R. In this case if the data frame is not NULL , then what is in the empty data frame and when it will be NULL . Thanks 回答1: df is not NULL because it is a data frame and thus has some defined properties. For

how to toast a message if editText is empty by clicking button?

我的梦境 提交于 2019-12-20 04:51:27
问题 i have 2 edit Text in my application, 1 button to add the input numbers in the edit Text and 1 text view to display the result. I would like to put a toast message if my edit text tab is empty or null when i click the button. I have searched and tried all the solutions..and nothing seems to work. help please!! here is my code for adding the two numbers. MainActivity.java package com.example.mycalc; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android

Fast test if directory is empty

自古美人都是妖i 提交于 2019-12-18 21:48:28
问题 What is the fastest way to test if a directory is empty? Of course I can check the length of list.files(path, all.files = TRUE, include.dirs = TRUE, no.. = TRUE) but this requires enumerating the entire contents of the directory which I'd rather avoid. EDIT : I'm looking for portable solutions. EDIT^2 : Some timings for a huge directory (run this in a directory that's initially empty, it will create 100000 empty files): system.time(file.create(as.character(0:99999))) # user system elapsed # 0

How to check if a date cell in Excel is empty?

流过昼夜 提交于 2019-12-18 07:45:09
问题 If feels like this should be really easy but I dont get it to work without retrieving the value of the cell again. To start with, I have 2 date cells: Dim agreedDate As Date Dim completedDate As Date THIS WORKS .. (but looks messy) agreedDate = Worksheets("Data").Cells(Counter, 7).Value completedDate = Worksheets("Data").Cells(Counter, 9).Value If (IsEmpty(Worksheets("Data").Cells(Counter, 7).Value) = True) Or (IsEmpty(Worksheets("Data").Cells(Counter, 9).Value) = True) Then [.. do stuff] End

Using if(!empty) with multiple variables not in an array

萝らか妹 提交于 2019-12-17 18:18:58
问题 I am trying to polish some code with the if(!empty) function in PHP but I don't know how to apply this to multiple variables when they are not an array (as I had to do previously) so if I have: $vFoo = $item[1]; $vSomeValue = $item[2]; $vAnother = $item[3]; Then I want to print the result only if there is a value. This works for one variable so you have: if (!empty($vFoo)) { $result .= "<li>$vFoo</li>"; } I tried something along the lines of if(!empty($vFoo,$vSomeValue,$vAnother) { $result .=

Check string for nil & empty

社会主义新天地 提交于 2019-12-17 17:38:05
问题 Is there a way to check strings for nil and "" in Swift? In Rails, I can use blank() to check. I currently have this, but it seems overkill: if stringA? != nil { if !stringA!.isEmpty { ...blah blah } } 回答1: If you're dealing with optional Strings, this works: (string ?? "").isEmpty The ?? nil coalescing operator returns the left side if it's non-nil, otherwise it returns the right side. You can also use it like this to return a default value: (string ?? "").isEmpty ? "Default" : string! 回答2:

Checking if a collection is empty in Java: which is the best method?

ε祈祈猫儿з 提交于 2019-12-17 15:29:57
问题 I have two ways of checking if a List is empty or not if (CollectionUtils.isNotEmpty(listName)) and if (listName != null && listName.size() != 0) My arch tells me that the former is better than latter. But I think the latter is better. Can anyone please clarify it? 回答1: You should absolutely use isEmpty() . Computing the size() of an arbitrary list could be expensive. Even validating whether it has any elements can be expensive, of course, but there's no optimization for size() which can't