In your question you outline:
print_r($feed->length);
It returned 1 in localhost, but blank in server.
Most likely you've got an error on your server. On your server you have to enable PHP error logging and set the error level to at least notices. Then you have to reproduce the "blank in server" situation. Afterwards you should find some error information in your error log, for example
Notice: Trying to get property of non-object
(this message is exemplary, yours might vary. You will be also given a filename where the error occurred and a line number.)
You can then use the PHP manual to review used functions, methods and language constructs at the location around the line where the error occurred and as well other curated resources like the PHP error reference we have on site to solve the issue.