Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing strings as an array index PHP
    primarykey
    data
    text
    <p>I'm really stumped on this one. I have this array variable <code>$banner_image_description</code>. When I print it I get <code>Array ( ['title'] =&gt; dafha ['price'] =&gt; adhfadhf )</code>. </p> <p>Now, what I'm trying to do is check the length of the value at 'title' and make sure it is more than 2. So when I run :</p> <pre><code>if (isset($this-&gt;request-&gt;post['banner_image'])) { foreach ($this-&gt;request-&gt;post['banner_image'] as $banner_image_id =&gt; $banner_image) { foreach ($banner_image['banner_image_description'] as $language_id =&gt; $banner_image_description) { print_r($banner_image_description); echo('&lt;br/&gt;'); if ((utf8_strlen($banner_image_description['title']) &lt; 2) || (utf8_strlen($banner_image_description['title']) &gt; 64)) { $this-&gt;error['banner_image'][$banner_image_id][$language_id] = $this-&gt;language-&gt;get('error_title'); } } } } </code></pre> <p>I get <code>Notice: Undefined index: title</code> and I have no idea why. I thought this was the correct way to go about getting the value at 'title' and I know the index is there and the value is there.</p> <p>I am pretty sure that the array is being populated by POSTing form values:</p> <pre><code>if (isset($this-&gt;request-&gt;post['banner_image'])) { $banner_images = $this-&gt;request-&gt;post['banner_image']; } </code></pre> <p>Here is what the form values look like:</p> <pre><code>&lt;input type="text" name="banner_image[&lt;?php echo $image_row; ?&gt;][banner_image_description][&lt;?php echo $language['language_id']; ?&gt;]['title']" value="&lt;?php echo isset( $banner_image['banner_image_description'][$language['language_id']]['title']) ? $banner_image['banner_image_description'][$language['language_id']]['title'] : ''; ?&gt;" /&gt; &lt;img src="view/image/flags/&lt;?php echo $language['image']; ?&gt;" title="&lt;?php echo $language['name']; ?&gt;" /&gt;&lt;br /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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