开发者

PHP ARRAY - remove certain array value

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜