Jump to content

How to remove characters from the result


Jacq
Go to solution Solved by litebearer,

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
 
 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.