Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert object to integer in PHP

Tags:

types

php

  • 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?

like image 259
ryonlife Avatar asked Dec 03 '22 16:12

ryonlife


1 Answers

Does this work?

$val = intval($total_results->getText());
like image 164
Sean Bright Avatar answered Dec 21 '22 23:12

Sean Bright