M
M
myspace2017-03-01 11:01:41
Programming
myspace, 2017-03-01 11:01:41

What is this technique called in programming?

$data = [null, null, null];
    $empty = true;

    foreach($data as $item) {

        if(!empty($item)) {
            $empty = false;
            break;
        }

    }

    return $empty ? null : $data;

if at least one $data index is not null, then the variable is assigned, which is then checked and, depending on its value, the value of the function\method is returned. I often see this, I want to understand if such a technique has a name.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question