I want to replace 4~8string characters *, how do I do this?
4~8
*
HelloWorld => Hell****ld
using
substr_replace()
as
substr_replace($string, '****', 4 , 4);
more details:
http://php.net/manual/en/function.substr-replace.php
<?php $var="HelloWorld"; $pattern="/oWor/"; $replace="****"; echo preg_replace($pattern,$replace,$var); ?>
$string = 'HelloWorld'; for ($i = 4; $i <= 8; ++$i) { $string[$i] = '*'; }
But there are many, many more ways to do this.
$var="HelloWorld"; $result=substr_replace($var, '****', 4,4 ) . "<br />\n";
You will need to use substr_replace () .
$str = substr_replace("HelloWorld","****",3,-2);
$str="HelloWorld"; print preg_replace("/^(....)....(.*)/","\\1****\\2",$str);
Source: https://habr.com/ru/post/1738448/More articles:Android ViewFlipper + Gesture Detector - androidadd in the middle of NSString in iPhone - iphoneMemory mapped files and soft page errors. Inevitable? - memory-mapped-filesHow to create an Emacs SQL buffer? - sqlShort hand for the number of tags having a longer [and almost the same] Xpath - xpathПолучение начального ярлыка в С# - c#A set of an unordered data type with a given order - setHow to get InnoSetup to create a deletion log file - installerNHibernate IUserType converts a nullable DateTime to a non-zero value - nullableC # TextBox Autocomplete (Winforms) key events and settings? - autocompleteAll Articles