Search
 
SCRIPT & CODE EXAMPLE
 

PHP

remove word from string php

<?php
// IF ONLY CHARACTER IN STRINGS
$str = "Hello PHP";
echo str_replace("PHP","",$str); // its remove PHP From string
//Output = Hello;

// IF NUMARIC OR CHARACTERS IN STRING AND YOU NEED ONLY STRING
$strInt = "124Peter56";
echo $words = preg_replace('/[0-9]+/', '', $strInt); // it remove integer from string
// Output = Peter;

// IF NUMARIC OR CHARACTERS IN STRING AND YOU NEED ONLY INTEGERS
$strInt = "124Peter56";
echo $res = preg_replace("/[^0-9]/", "", $strInt ); // It Remove all string 
// Output = 12456
?>
Comment

PREVIOUS NEXT
Code Example
Php :: how to migrate just one table in laravel 
Php :: php storage link 
Php :: php pdo last insert id 
Php :: print query statement in laravel 
Php :: php convert string to date 
Php :: php wait 
Php :: laravel tinker update password 
Php :: laravel collection reverse 
Php :: rout debug symfony command 
Php :: laravel check collection not empty 
Php :: storage link laravel 
Php :: a2dismod 
Php :: php if url contains 
Php :: php regex only number 
Php :: composer install ignore 
Php :: php curl timeout 
Php :: how uninstall the laravel 
Php :: str slug laravel 
Php :: php artisan db:seed Call to undefined method AppModelsProduct::factory() 
Php :: date_default_timezone_set india 
Php :: install zip php extension 
Php :: get cart page url in woocommerce 
Php :: laravel favicon 
Php :: laravel ide helper 
Php :: php string mayusculas 
Php :: php time limit 
Php :: count object php 
Php :: php get everything after last slash 
Php :: session has laravel blade 
Php :: htaccess set php memory limit 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =