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 :: How to write a loop in PHP 
Php :: laravel validation date 
Php :: Passing PHP Arrays to JavaScript 
Php :: wordpress escape string 
Php :: trim array in map php 
Php :: What does "as" keyword mean in Laravel route ? 
Php :: php check if entire array are in another array 
Php :: laravel blade empty 
Php :: php cheatsheet 
Php :: how to insert date in mysql using php 
Php :: Unable to connect with STARTTLS: stream_socket_enable_crypto(): SSL operation failed with code 1 
Php :: convert text file to json php 
Php :: php imagick xampp windows 
Php :: textarea laravel migration 
Php :: woocommerce add to cart hook 
Php :: laravel redirect to controller method 
Php :: laravel resource route 
Php :: arrow function in php 
Php :: PHP utf8_encode — Converts a string from ISO-8859-1 to UTF-8 
Php :: php server function 
Php :: sort json in php 
Php :: laravel drop foreign key 
Php :: php interface vs abstract class 
Php :: Laravel assets url issue 
Php :: laravel order by numbers 
Php :: pdo prepare 
Php :: uppercase php 
Php :: php check if text is blank 
Php :: make full laravel model ( with migration, controller and resource ) 
Php :: laravel module make migration 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =