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 Quote Link to comment https://forums.phpfreaks.com/topic/279720-how-to-remove-characters-from-the-result/ Share on other sites More sharing options...
Solution litebearer Posted June 30, 2013 Solution Share Posted June 30, 2013 $my_desired_value = $str_arr[0]; echo $my_desired_value; or simply echo $str_arr[0]; Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.