Simple_HTML_DOM将“find”值解析为Integer

I'm studying Simple_HTML_DOM and I found a problem where I'm working on from 2 hours without finding a solution :-(

I've the following code:

$num = $html->find('span.pageNum');    

This code get number of pages on my blog and it works. GREAT.

If I do

echo $num[0];    

I see the number of pages on screen, but if I try to do something like:

echo ($num[0]+2);    

for example, It doesen't work like an INTEGER and it return me the following output:

3    

So, I need to make the "find" to an integer and work for math operations but I tried everything and nothing works (like cast with (int)$num[0] and much more).

Can anyone please help me? I don't know what to do more...I really tried everything!! :-(

Thanks in advance!!

FOUND THE SOLUTION!! I used:

$pgnum = filter_var($num[0], FILTER_SANITIZE_NUMBER_INT);

worked GREAT!! Thanks :-)