Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter view only outputting single character from array
    text
    copied!<p>I'm trying to output strings to form an image path, the strings are held in a nested array at the deepest level.</p> <p>My loop iterates over all array contents at this level but only outputs the first letter from the array content and I cant figure out why.</p> <p>So I need a bit of help, here's what I have...</p> <p>Array dump:</p> <pre><code>Array ( [0] =&gt; Array ( [p_name] =&gt; Shops [p_startdate] =&gt; foo [p_enddate] =&gt; bar [p_elapsed] =&gt; hello [p_rag] =&gt; Array ( [0] =&gt; grayNodePng6160.png [1] =&gt; grayNodePng6160.png [2] =&gt; grayNodePng6160.png [3] =&gt; grayNodePng6160.png [4] =&gt; grayNodePng6160.png [5] =&gt; grayNodePng6160.png [6] =&gt; grayNodePng6160.png [7] =&gt; grayNodePng6160.png [8] =&gt; grayNodePng6160.png ) ) ) </code></pre> <p>Controller index method</p> <pre><code>public function index() { $data = array(); $data['splash_projects'] = $this-&gt;generate_projects(); $this-&gt;load-&gt;view('include/header'); $this-&gt;load-&gt;view('include/navigation'); $this-&gt;load-&gt;view('splash', $data); $this-&gt;load-&gt;view('include/footer'); } </code></pre> <p>Controller helper method:</p> <pre><code> private function generate_projects(){ $projects = array( array ( "p_name" =&gt; "Shops", "p_startdate" =&gt; "foo", "p_enddate" =&gt; "bar", "p_elapsed" =&gt; "hello", "p_rag" =&gt; array ('grayNodePng6160.png', 'grayNodePng6160.png','grayNodePng6160.png','grayNodePng6160.png','grayNodePng6160.png', 'grayNodePng6160.png','grayNodePng6160.png','grayNodePng6160.png','grayNodePng6160.png') ) ); return $projects; } </code></pre> <p>View:</p> <pre><code> &lt;?php if($splash_projects!==false):?&gt; &lt;?php foreach ($splash_projects as $sproject):?&gt; &lt;div class="container"&gt; &lt;div class="row"&gt; &lt;p class="section-paragraph"&gt;Project Name :&lt;?php echo $sproject['p_name']?&gt;&lt;/p&gt; &lt;p class="section-paragraph"&gt;Start Date: &lt;?php echo $sproject['p_startdate']?&gt;&lt;/p&gt; &lt;p class="section-paragraph"&gt;End Date: &lt;?php echo $sproject['p_enddate']?&gt;&lt;/p&gt; &lt;ul&gt; &lt;?php foreach($sproject['p_rag'] as $rag):?&gt; &lt;?php $x=0 ?&gt; &lt;li&gt;&lt;img class="section-paragraph"&gt;Overview: &lt;?php echo $rag[$x] ?&gt;&lt;/img&gt;&lt;/li&gt; &lt;?php endforeach?&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php endforeach?&gt; &lt;?php endif?&gt; </code></pre> <p>This is the output - Overview: g, I get this line printed once for each element in the array.</p> <p>The full path info isn't there yet I'm just trying to get the dynamic data out first.</p> <p>Can anybody help? Many Thanks.</p>
 

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