Is there any function or method to remove array value for example, i have an array like this:
Array (
[0] => (Some string value)51351
[1] => (Some string value)43822
)
So the question is, How do i get the 开发者_StackOverflow中文版value that is not in the "( )". and counting the value of array after remove "( Some string value )" to do some looping process?
Thank you!
<?php
function digits_only($str){
return preg_replace("/\(.*\)/", "", $str);
}
$arr = array("(Some content)531", "(Another Content)613");
$digits_array = array_map("digits_only", $arr);
var_dump($digits_array);
echo array_sum($digits_array);
Live Demo:
http://codepad.org/mYPL3PYH
精彩评论