Hi,
Is it possible to extract the remaining string followed by the escape character.
Ex: string x6a-s_14, x6a-s_1 etc.,
I need to get the last interger part i.e 14, 1 respectively
Is this possible?
extract string followed by escape character
Moderator: General Moderators
you could explode string on comma, loop through that array and then explode on underscore...
http://www.php.net/manual/en/function.explode.php
kinda like this..
http://www.php.net/manual/en/function.explode.php
kinda like this..
Code: Select all
$firstarray=explode("," $originalstring);
foreach($firstarray as $key=>$val){
$secondarray=explode("_" $val);
echo $secondarrayї1];
}Or continue tweaking:
Code: Select all
<?php
$string = ' x6a-s_14, x6a-s_1, x6a-s_14, x6a-s_14, x6a-s_144, x6a-s_1234';
$array = explode(",",str_replace('x6a-s_','',$string));
print_r($array);
?>