Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php find first occurrence in string

#You can use the strpos() function 

$cheese = "cheese";

strpos($cheese, 'h');

#Output: 1
Comment

PHP strstr — Find the first occurrence of a string

<?php
$email  = 'name@example.com';
$domain = strstr($email, '@');
echo $domain; // prints @example.com

$user = strstr($email, '@', true);
echo $user; // prints name
?>
Comment

PREVIOUS NEXT
Code Example
Php :: pg_dump with user name password 
Php :: laravel select multiple value in form edit 
Php :: php split large text on line breaks into array 
Php :: laravel json response 
Php :: add custom helper laravel 
Php :: how to get shop page url in wordpress 
Php :: php return function result to variable 
Php :: check laravel first null 
Php :: php count 
Php :: how to combine variables and text into a string php 
Php :: php artisan create controller inside folder 
Php :: if session is empty laravel 
Php :: php object 
Php :: how to create access token in laravel 
Php :: laravel eloquent get specific columns using with function 
Php :: get_categories not__in 
Php :: laravel target is not instantiable while building 
Php :: laravel 8 query builder 
Php :: php http authentication 
Php :: install php version 7.3 ubuntu 
Php :: notify multiple users laravel 
Php :: how to fetch data from url in php properly 
Php :: laravel amount migration 
Php :: php class extends exception 
Php :: add controller to laravel with requests 
Php :: laravel pagination layout issue 
Php :: woocommerce change add to cart button text 
Php :: Laravel: Set timestamp column to current timestamp 
Php :: php include 
Php :: laravel collection has 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =