Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I create array using while loop
    primarykey
    data
    text
    <p>==================================================================================</p> <p><strong>Solution Code:</strong></p> <pre><code>$array = array(); $i = 1; while( $i &lt;= $instance['posts_num'] ) { $array['tab'.$i.'_title'] = 'Category Heading'; $array['tab'.$i.'_thumb'] = 'Insert link here'; $array['tab'.$i.'_featured'] = 'Insert link here'; $array['tab'.$i.'_description'] = 'Insert category desciption'; $array['tab'.$i.'_link'] = 'Insert category link'; $i += 1; } $instance = wp_parse_args( (array)$instance, array( 'heading' =&gt; 'Featured Area', 'title' =&gt; '', 'posts_num' =&gt; 1, (array) $array ) ); </code></pre> <p>==================================================================================</p> <p>how can I create array with while loop.</p> <p>I am trying to create an array with the help of while loop in simple wordpress plugin. my codes are below:</p> <pre><code> $instance = wp_parse_args( (array)$instance, array( 'heading' =&gt; 'Featured Area', 'title' =&gt; '', 'posts_num' =&gt; 1, $array = array(); $i = 1; while( $i &lt;= $instance['posts_num'] ) { $array[] = 'tab'.$i.'_title' =&gt; 'Category Heading', $array[] = 'tab'.$i.'_thumb' =&gt; 'Insert link here', $array[] = 'tab'.$i.'_featured' =&gt; 'Insert link here', $array[] = 'tab'.$i.'_description' =&gt; 'Insert category desciption', $array[] = 'tab'.$i.'_link' =&gt; 'Insert category link', $i += 1; } ) ); </code></pre> <p>I just want to confirm if i am doing correctly.</p> <p>I want to generate array like this :</p> <pre><code>'tab1_title' =&gt; 'Category Heading', 'tab1_thumb' =&gt; 'Insert link here', 'tab1_featured' =&gt; 'Insert link here', 'tab1_description' =&gt; 'Insert category desciption', 'tab1_link' =&gt; 'Insert category link', 'tab2_title' =&gt; 'Category Heading', 'tab2_thumb' =&gt; 'Insert link here', 'tab2_featured' =&gt; 'Insert link here', 'tab2_description' =&gt; 'Insert category desciption', 'tab2_link' =&gt; 'Insert category link', </code></pre>
    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.
 

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