Jump to content

How to remove characters from the result


Jacq

Recommended Posts

Welcome

How to remove characters from the result.

When I try to delete characters I have error

 

Code:

 

function getInbetweenStrings($start, $end, $str){
    $regex = "/$start([a-zA-Z0-9_]*)$end/";
    preg_match_all($regex, $str, $matches);
    return $matches[1];
}
 
$text ='<input type="hidden" name="elementId" value="1826" id="elementId">';
$str = $text;
$str_arr = getInbetweenStrings('<input type="hidden" name="elementId" value="', '" id="elementId">', $str);
 
print_r($str_arr);
 
 
The result of this code looks like this
Array ( [0] => 1826 )
I just want 1826
and when i change print_r($str_arr); to echo $str_arr; then code writes me just Array not even Array ( [0] => 1826 ).
 
Do you have any advice on the code
 
 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.