2

I have the following code that gets results from Wolfram Alpha:

<?php
include 'WolframAlphaEngine.php';
$engine = new WolframAlphaEngine( 'API-KEY' );

$resp = $engine->getResults("2+2");

$pod = $resp->getPods();

$pod = $pod[1];

foreach($pod->getSubpods() as $subpod){
  if($subpod->plaintext){
    $plaintext = $subpod->plaintext;
    break;
  }
}

$result = substr($plaintext, 0,strlen($plaintext)-3);

echo $result;
?>

If I search for text such as "George W Bush" it displays what it should, but if I search equations such as 2+2 then it doesn't show the results. Any clues?

derekshull
  • 305
  • 1
  • 2
  • 14

1 Answers1

1

Use $plaintext instead of result. Not sure why it works...it just does.

derekshull
  • 305
  • 1
  • 2
  • 14