How to determine if array elements are not spaces in php

青灯夜游
Release: 2023-03-12 11:06:02
Original
1958 people have browsed it

Methods to determine if array elements are not spaces: 1. Use the "foreach ($arr as $value){}" statement to traverse the array; 2. Use the "if($value!=" ")" statement to determine Whether the array elements are spaces; 3. If all array elements are not empty, output "array elements are not spaces".

How to determine if array elements are not spaces in php

The operating environment of this tutorial: Windows 7 system, PHP version 7.1, DELL G3 computer

php determines that the array element cannot be a space

Idea:

  • Use the foreach statement to traverse the array, and assign the key value of the current array to $value## in each loop

  • #In the loop body, use the if statement to determine whether the array element is a space

    • If it is not a space, then

      $i

    • If it is a space, set

      $i=0, and usebreak;to exit the entire loop.

  • Use the if statement to determine whether the

    $i valueis 0, then you can know whether there is a space element in the array

Implementation code:

Copy after login

Output result:


How to determine if array elements are not spaces in php## Recommended learning: "

PHP video tutorial

The above is the detailed content of How to determine if array elements are not spaces in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!