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 :: checking php version 
Php :: php replace multiple spaces end chrters to one 
Php :: php make array to certain length 
Php :: required field in laravel admin 
Php :: artisan refresh 
Php :: SSL PHP CURL 
Php :: php remove html tags 
Php :: convert number to 2 decimal places in php 
Php :: mac install multiple php versions 
Php :: php from 
Php :: create new laravel project cmd 
Php :: option value selected in laravel blade 
Php :: Limit Product Name in Magento2 
Php :: specified key was too long max key length is 767 bytes 
Php :: php call protected function from child class 
Php :: counting time execution duration in time laravel 
Php :: implode php 
Php :: default null migration laravel 
Php :: php remove warning 
Php :: wordpress get link to post by id 
Php :: create a user using tinker 
Php :: run composer with different php version 
Php :: time zone set in codeigniter 
Php :: php header location not working 
Php :: php curl 
Php :: mysql count rows php 
Php :: curl exec not working php 
Php :: laravel transform object to array 
Php :: get url parameters in laravel blade 
Php :: laravel eloquent get column 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =