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 :: login form tutorialpoint 
Php :: bool value of blank string inp php 
Php :: download file on client from server url php 
Php :: laravel telescope tutorial 
Php :: what is the use of migration file in laravel 
Php :: CODEIGNITER codeigniter 4 auth 
Php :: how to migrate new column without empty the table in laravel 
Php :: Laravel catch TokenMismatchException 
Php :: How to insert header in php 
Php :: php code add text on existing pdf file 
Php :: php typecast class 
Php :: yajra datatables html column bulder example 
Php :: Laravel factory creating tempory data 
Php :: laravel create get id 
Php :: how to make primary key and foreign key in phpmyadmin 
Php :: if else in one line php 
Php :: php return multiple variables from function 
Php :: codeigniter sms send 
Php :: php isset 
Php :: how to catch duplicate entry to database in laravel 
Php :: create crud controller in laravel 5.8 
Php :: How to add .active class to active menu item 
Php :: API json data show in laravel 
Php :: laravel set middleware default 
Php :: create symfony project 
Php :: string to lowercase accentuation hyphenated 
Php :: Mixed int and string keys 
Php :: movies -inurl:(htm|html|php|pls|txt) intitle:index.of “last modified” (mp4|wma|aac|avi) 
Php :: php run server laravel 
Php :: breaks the collection into multiple smaller collections Laravel 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =