-1
object(stdClass)#14 (9) { ["time"]=> int(1367856000) ["summary"]=> string(5) "Clear" ["icon"]=> string(9) "clear-day" ["precipType"]=> string(4) "rain" ["temperature"]=> float(61.43) ["apparentTemperature"]=> float(61.43) ["windSpeed"]=> float(6.08) ["windBearing"]=> int(134) ["pressure"]=> float(1010.98) } [10]=> 
object(stdClass)#15 (9) { ["time"]=> int(1367859600) ["summary"]=> string(5) "Clear" ["icon"]=> string(9) "clear-day" ["precipType"]=> string(4) "rain" ["temperature"]=> float(62.79) ["apparentTemperature"]=> float(62.79) ["windSpeed"]=> float(9.48) ["windBearing"]=> int(146) ["pressure"]=> float(1011.36) } [11]=>

Hello, could someone please help me with outputting specific var_dump data objects to string variables, which can later can be used to print/echo or insert into a database? I have seen many examples, but I still cannot find an example that works for me.

Roman
  • 1
  • So you want to know how you can access specific data from that object? – Rizier123 Jun 10 '16 at 00:23
  • Yes, that is correct. Using the following, I did a var_dump to an arra, but I am not sure how to call the variable e.g., "time". Notice: Undefined variable: summary $var_name=array($forecast->getHistoricalConditions('37.8267','-122.423', '2013-05-06T12:00:00-0400')); extract($var_name, EXTR_PREFIX_SAME, "dup"); echo "\$a = $summary"; – Roman Jun 10 '16 at 12:11
  • Then see: http://stackoverflow.com/q/30680938/3933332 – Rizier123 Jun 10 '16 at 12:15
  • Figured it out. Thanks Rizier123 – Roman Jun 14 '16 at 11:26

1 Answers1

0

You can 'echo' them out using the $classname->var?

If you would rather work with a simple array use

$string = json_encode($obj);
$array = json_decode($string,true);

You could also do a loop, and type set each $var to a string

foreach($object as $key -> $var)
{
$array_string[$key] = settype($var, "string");
}

You should end up with an array of strings, but all examples can be 'echo'ed out.

CapeCoder
  • 531
  • 6
  • 11