Answers for "Print all before characters once string found | matched string return"

PHP
0

Print all before characters once string found | matched string return

$headTag = "25%";
if(strpos($headTag, '%') !== false) {
	echo substr($headTag, 0 ,strpos($headTag, '%')); //25
}
$headTag = "100%";
if (strpos($headTag, '%') !== false) {
	echo substr($headTag, 0 ,strpos($headTag, '%')); //100
}
Posted by: Guest on April-15-2022

Code answers related to "Print all before characters once string found | matched string return"

Browse Popular Code Answers by Language