Jacq Posted June 30, 2013 Share Posted June 30, 2013 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 https://forums.phpfreaks.com/topic/279720-how-to-remove-characters-from-the-result/ Share on other sites More sharing options...
litebearer Posted June 30, 2013 Share Posted June 30, 2013 $my_desired_value = $str_arr[0]; echo $my_desired_value; or simply echo $str_arr[0]; Link to comment https://forums.phpfreaks.com/topic/279720-how-to-remove-characters-from-the-result/#findComment-1438725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.