tags:

views:

1146

answers:

4
  • The value of $total_results = 10
  • $total_results in an object, according to gettype()
  • I cannot use mathematical operators on $total_results because it's not numeric
  • Tried $total_results = intval($total_results) to convert to an integer, but no luck
  • The notice I get is: Object of class Zend_Gdata_Extension_OpenSearchTotalResults could not be converted to int

How can I convert to an integer?

+1  A: 
$results_numeric = (int) $total_results;

or maybe this:

$results_numeric = $total_results->count();
Karsten
No dice with either of those
chipotle_warrior
(int) does the same as calling intval().
Pim Jager
+1  A: 

Does this work?

$val = intval($total_results->getText());
Sean Bright
+1  A: 

perhaps the object has a build in method to get it as an integer?

Otherwise try this very hacky approach (relys on __toString() returning that 10)

$total_results = $total_results->__toString();
$total_results = intval($total_results);

However if the object has a build in non-magic method, you should use that!

Pim Jager
+1  A: 

You can see the methods of the class here. Then you can try out the different methods yourself. There is a getText() method for example.

Morten Christiansen
I'm new to OO, thanks for pointing out/reminding about methods of the class.
chipotle_warrior