Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeigniter XML Array explode php
    primarykey
    data
    text
    <p>I have a controller merchant_import and creating an array from xml </p> <pre><code>public function merchant_import_kgb(){ if (!$this-&gt;session-&gt;userdata('logged_in')){ redirect('admin/login'); } $data['pageTitle'] = 'Merchant Admin'; $data['error_warning'] = ''; $data['success'] = ''; $xmlfile= base_url().'feeds/kgb.xml'; $xmlRaw = file_get_contents($xmlfile); $this-&gt;load-&gt;library('xml'); $xmlData = $this-&gt;xml-&gt;xml_parse($xmlRaw); ?&gt;&lt;pre&gt;&lt;?php var_dump($xmlData); ?&gt;&lt;/pre&gt;&lt;?php foreach($xmlData['merchant']['prod'] as $product){ list($titleNew, $partner, $city) = explode(" - ", $product['text']['name']); $deal[] = array( 'id' =&gt; $product['pId'], 'dealTitle' =&gt; $titleNew, 'price' =&gt; $product['price']['buynow'], 'image' =&gt; $product['uri']['mThumb'], 'buyLink' =&gt; $product['uri']['awTrack'], 'endDate' =&gt; $product['valTo'], 'partner' =&gt; $partner, 'city' =&gt; $city, 'description' =&gt; $product['text']['desc'], 'RRP' =&gt; $product['price']['rrp'], 'category' =&gt; $product['cat']['mCat'], 'discount' =&gt; $this-&gt;getDiscount($product['price']['buynow'], $product['price']['rrp']) ); } ?&gt;&lt;pre&gt;&lt;?php var_dump($deal);?&gt;&lt;/pre&gt;&lt;?php } </code></pre> <p>The problem I am having is that the $parts[2] is giving an undefined offset with some and others its formating nicely. I have checked the xml and all titles are Title - Partner - City - kgbdeals. When formatting array though the explode() isn't working correctly. Any ideas? </p> <p>Edit - tried using preg_split(), split(), and explode all with near enough same result, totally lost :(</p> <p>Thanks Joe</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.
    1. This table or related slice is empty.
    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