Note that there are some explanatory texts on larger screens.

plurals
  1. POXML to Array? [PHP]
    primarykey
    data
    text
    <p>Well I been having issues changing an xml back into an array....It would be simple if each xml followed the same format but every XML is different with the exception of the <code>&lt;Formula&gt;</code> tag, formulaname and movespeed ex:</p> <pre><code>&lt;Formula&gt; &lt;formulaname&gt;Basic&lt;/formulaname&gt; &lt;movespeed&gt;1&lt;/movespeed&gt; &lt;str&gt;4&lt;/str&gt; &lt;dex&gt;3&lt;/dex&gt; &lt;int&gt;1&lt;/int&gt; &lt;will&gt;2&lt;/will&gt; &lt;/Formula&gt; </code></pre> <p>or</p> <pre><code>&lt;Formula&gt; &lt;formulaname&gt;Basic&lt;/formulaname&gt; &lt;movespeed&gt;1&lt;/movespeed&gt; &lt;box&gt;4&lt;/box&gt; &lt;chicken&gt;3&lt;/chicken&gt; &lt;ducks&gt;1&lt;/ducks&gt; &lt;cereal&gt;2&lt;/cereal&gt; &lt;/Formula&gt; </code></pre> <p>What I have tried:</p> <pre><code>$xml = simplexml_load_file("test.xml"); print_r($xml); </code></pre> <p>This actually <code>prints</code> something but I couldn't get past that or even <code>echo</code> it..</p> <pre><code>foreach($xml-&gt;text as $string) { print_r($string); echo 'attributes: '. $string-&gt;attributes() .'&lt;br /&gt;'; } </code></pre> <p>Didn't work, originally it's for <code>strings</code> but none of them are <code>strings</code>...</p> <pre><code>foreach ($xml-&gt;Formula as $element) { foreach($element as $key =&gt; $val) { echo "{$key}: {$val}"; } </code></pre> <p>Didn't work either, I needed something like this to work so I can use the values from the <code>array</code> without knowing what exactly the value will be called..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload