i want to search for a string that looks like:
Zpx Zpx;
while Z is N=(0,.......,100)
and replace the string to:
Zpx 0px 0px Zpx;
hello help with string find & replace
Moderator: General Moderators
Re: hello help with string find & replace
Hello,
you can use preg_replace to achieve this.
Greets.
you can use preg_replace to achieve this.
Code: Select all
<?php
$string = "2px 3px;";
$pattern = "/(\d)px (\d)px\;/i";
$replace = "$1px 0px 0px $2px;";
$result = preg_replace($pattern, $replace, $string);
echo $result;