Php - How to split numbers from string, Split numbers from string
How to split numbers from string
Split Numbers From String Using PhpTo split numbers present at last of a string and increment the number by 1 using php
$vname="words9999"; echo "Initial value==".$vname; $i = 1; $strln=strlen($vname); for($j=0;$j<=$strln;$j++) { $nm=substr($vname,-$j); if (!preg_match('/[^0-9]/', $nm)) { $vnameapp=$nm; } } $vnam=explode($vnameapp,$vname); $vnameapp++; $vname=$vnam[0].$vnameapp; echo "The final value of vname=".$vname;
The output will be
Initial value==words9999 The final value of vname=words10000
The topic on Php - How to split numbers from string is posted by - Namo
Hope you have enjoyed, Php - How to split numbers from stringThanks for your time