I am using Resellers Panel API for the following question. (documentation)

I have a Curl script with a foreach within it. That is getting the country list from the resellers panel api. 

function getCountries() {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "myapiurl");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, POST);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $final = curl_exec($ch);
    $result = explode(" ", $final);

        echo '&lt;select&gt;';
        foreach ($result as $country =&gt; $name) {
            echo '&lt;option&gt;'.$country. '&lt;/option&gt;';
        }

        echo '&lt;/select&gt;';

    curl_close($ch);
}


The above code is resulting in: 

&lt;select&gt; 
   &lt;option&gt;1&lt;/option&gt;
   &lt;option&gt;2&lt;/option&gt;
&lt;/select&gt;


This continues for all 114 countries listed. I didn't feel the need to place all 114 options here. 

It appears as if the foreach is just counting each result from the curl and posting that in the select. How would I get this to actually echo out the country name rather than just count? 

In raw form the API results just like so: For example, only one country is listed. 

&lt;ampa&gt;
  &lt;command&gt;"0"
  &lt;error_code&gt;0&lt;/error_code&gt;
  &lt;countries&gt;
    &lt;n0&gt;
      &lt;name&gt;Afghanistan&lt;/name&gt;
      &lt;iso2&gt;AF&lt;/iso2&gt;
      &lt;phone_code&gt;93&lt;/phone_code&gt;
    &lt;/n0&gt;
 &lt;/countries&gt;
&lt;/ampa&gt;


UPDATE 

I tried echo '&lt;option value="'.$country.'"&gt;'.$name. '&lt;/option&gt;'; and it resulted in the following: 

&lt;option value="0"&gt;
0
0
56000


        Afghanistan
        AF
        93


        Albania
        AL
        355


        Algeria
        DZ
        213


        American&lt;/option&gt;


When I echo out $final, I receive this (in short): 

0 0 56000 Afghanistan AF 93 Albania AL 355 Algeria DZ 213 American Samoa AS 684 Andorra AD 376 Angola AO 244 Anguilla AI 1 Antarctica AQ 672 AG 1 Argentina AR 54 Armenia AM 374 Aruba AW 297 Australia AU 61 Austria AT 1 0 0.2 43


And I would like to be able to echo out the country name in a select using a foreach statement. 

ex: 

&lt;select&gt;
 &lt;option&gt;United States&lt;/option&gt;
&lt;/select&gt;



Question: Do real and reactive energy exist?
Answer: First of all, remember that in the context of AC (phasor) analysis, real and reactive power, unlike voltage and current, are not phasors, i.e., they do not represent the amplitude and phase of a sinusoid in the time domain.  Thus, we cannot "tack on" the time dependence and take the real and imaginary parts to calculate the associated energies in time domain.  

Sometimes it is helpful to "go back to basics" to gain insight into a problem.  This is such a case.  Reactive power is a useful concept in AC analysis but what it represents physically is best seen in the time domain.

First, consider a sinusoidal voltage source \$v_s(t) = V\cos\omega t\$ driving a resistor R.  The power delivered to the resistor is:

$$p_R = \dfrac{v^2_s(t)}{R} = \dfrac{V^2\cos^2\omega t}{R} = \dfrac{V^2}{2R}(1 + \cos2\omega t)$$

The key observation here is that the power is never negative, i.e., the flow of energy is from the source to the resistor always.  Thus, the energy supplied by the source increases over time.

The energy supplied by the source over a period \$\dfrac{\pi}{\omega}\$ is:

$$W_R = \dfrac{\pi V^2}{2\omega R}$$

Now, replace the resistor with a capacitor.  The power delivered to the capacitor is:

$$p_C = v_s(t) \cdot i_C =  V\cos\omega t \cdot (-\omega C)V\sin\omega t = -\dfrac{CV^2}{2}\sin2\omega t$$

The energy supplied by the source over a period \$\dfrac{\pi}{\omega}\$ is:

$$W_C = 0 $$

The key observation here is that the power is alternately and equally positive and negative, i.e., the flow of energy is back and forth between the source and the capacitor.  Thus, the energy supplied by the source over a period is zero.

But, as we know, the power associated with a capacitor is reactive power in phasor analysis, and now we can answer your question:


  Are there any such things as real and reactive energies


We have shown that reactive power is associated with an alternating energy flow between the source and load that is zero over a period.  In other words, it is associated with the energy that "sloshes" back and forth between the source and load without any dissipation.