Search
 
SCRIPT & CODE EXAMPLE
 

PHP

check string in php

$names = array("Maria", "Jhon", "John", 777, "Michael");

    foreach ($names as $check) {
        if(is_string($check)) {
            echo "This is a string: ". $check. "<br>";
        } else {
            echo "This is not a string: ".$check. "<br>";
        }
    }

// using foreach and is_string menthods
// If you want to check an array if it contains number or not
Comment

php check string

// if you want to test content of a string to match a model

//You should use a regex filter with preg_match who returns 1 or 0

// this filter works for most of cases

/* use this regex */ preg_match("/^[a-z ,.'-]+$/i", your_string);

if you want more regex filters you can make yours on 'https://regex101.com/'
Comment

PREVIOUS NEXT
Code Example
Php :: how count the rout in route.php laravel 
Php :: get number of chars ina string php 
Php :: php append line to file 
Php :: Target class [FruitcakeCorsHandleCors] does not exist. 
Php :: woocommerce get user id by email 
Php :: woocommerce add custom field data to cart page 
Php :: flutter form autadjust height 
Php :: laravel auth ui command 
Php :: how to get previous month in php 
Php :: php index of last element in array 
Php :: laravel table in model 
Php :: wordpress get child posts 
Php :: composer cache clean 
Php :: Database//Eloquent//Model.php laravel errror array t- string conversion 
Php :: php validate date format 
Php :: how run phpunit test repeat 
Php :: get last month php 
Php :: get raw query laravel 
Php :: laravel gigapay 
Php :: date format in laravel month name day name 
Php :: update-alternatives java 
Php :: artisan mograte particular tabel 
Php :: format date in laravel using carbon 
Php :: add acf options page 
Php :: laravel current date in migration 
Php :: how to create a logfile in php? 
Php :: laravel change column 
Php :: how to pass id through get template part 
Php :: PHP strtotime() Function 
Php :: laravel log to console 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =