I am failing to see the connection between the first block of code and the second block with $kookoo in it?
Anyhow, in any operation involving type-juggling (such as intval()) you are best doing a
var_dump( $kookoo);
both before and after the operation and that way it will point to what PHP is understanding that variable to actually contain in terms of type and value, and usually turns up why it is not what you expect.