If your string represents a number such as "6" or "123" you just have to cast you string into an integer like this :
$str = "123";
$num = (int)$str;
Well now if your string represents something else that a number you'll get 0
$str = "hello";
$num = (in)$str; // $num == 0