How to explode comma separated arrays from databaseDeleting an element from an array in PHPHow do I get a YouTube video thumbnail from the YouTube API?Reference — What does this symbol mean in PHP?How to pass an array within a query string?PHP: how to combine foreach and explodeExplode and then merge arraysArray to comma separated stringsPhp build array from comma separated array valuesHow to convert comma separated string to key value array in phpGet rows from Database from comma-separated value

For the erase-remove idiom, why is the second parameter necessary which points to the end of the container?

How did Thanos not realise this had happened at the end of Endgame?

How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?

51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?

Does Lawful Interception of 4G / the proposed 5G provide a back door for hackers as well?

A curve pass via points at TiKz

How are one-time password generators like Google Authenticator different from having two passwords?

Why does the Earth follow an elliptical trajectory rather than a parabolic one?

On studying Computer Science vs. Software Engineering to become a proficient coder

What are the implications of the new alleged key recovery attack preprint on SIMON?

How can this pool heater gas line be disconnected?

Front derailleur hard to move due to gear cable angle

SSD - Disk is OK, one bad sector

Why does getw return -1 when trying to read a character?

How does Howard Stark know this?

Why do Thanos's punches not kill Captain America or at least cause some mortal injuries?

Is the schwa sound consistent?

Drawing lines to nearest point

Can I make ravioli dough with only all-purpose flour or do I NEED semolina flour?

Meaning of「〜てみたいと思います」

What is the best way for a skeleton to impersonate human without using magic?

What is Plautus’s pun about frustum and frustrum?

What does i386 mean on macOS Mojave?

tikz: not so precise graphic



How to explode comma separated arrays from database


Deleting an element from an array in PHPHow do I get a YouTube video thumbnail from the YouTube API?Reference — What does this symbol mean in PHP?How to pass an array within a query string?PHP: how to combine foreach and explodeExplode and then merge arraysArray to comma separated stringsPhp build array from comma separated array valuesHow to convert comma separated string to key value array in phpGet rows from Database from comma-separated value






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I am unable to explode comma separated data array from the database in codeigniter framework. I want to echo the array into multiple rows with string value like:



---------------
Product Name
---------------
Product 1
Product 2
Product 3



But i am getting array to string conversion error.



<?php foreach ($res as $key => $value) ?>
<tr class="border-bottom">
<td>
<?php $prodArray = $value->product;
echo explode(',',$prodArray) ?>
</td>
</tr>
<?php ?>


So, how can i explode and fetch the data in codeigniter










share|improve this question






















  • are you facing any error?

    – M.Hemant
    Mar 23 at 11:58











  • echo explode(',',$prodArray) this line is just wrong. You can't echo an array like this.

    – Eduardo Junior
    Mar 23 at 12:02












  • Please, post a $res array format example.

    – Eduardo Junior
    Mar 23 at 12:03












  • You can convert an array to a string: $arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;

    – Jamie_D
    Mar 23 at 12:23

















-1















I am unable to explode comma separated data array from the database in codeigniter framework. I want to echo the array into multiple rows with string value like:



---------------
Product Name
---------------
Product 1
Product 2
Product 3



But i am getting array to string conversion error.



<?php foreach ($res as $key => $value) ?>
<tr class="border-bottom">
<td>
<?php $prodArray = $value->product;
echo explode(',',$prodArray) ?>
</td>
</tr>
<?php ?>


So, how can i explode and fetch the data in codeigniter










share|improve this question






















  • are you facing any error?

    – M.Hemant
    Mar 23 at 11:58











  • echo explode(',',$prodArray) this line is just wrong. You can't echo an array like this.

    – Eduardo Junior
    Mar 23 at 12:02












  • Please, post a $res array format example.

    – Eduardo Junior
    Mar 23 at 12:03












  • You can convert an array to a string: $arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;

    – Jamie_D
    Mar 23 at 12:23













-1












-1








-1








I am unable to explode comma separated data array from the database in codeigniter framework. I want to echo the array into multiple rows with string value like:



---------------
Product Name
---------------
Product 1
Product 2
Product 3



But i am getting array to string conversion error.



<?php foreach ($res as $key => $value) ?>
<tr class="border-bottom">
<td>
<?php $prodArray = $value->product;
echo explode(',',$prodArray) ?>
</td>
</tr>
<?php ?>


So, how can i explode and fetch the data in codeigniter










share|improve this question














I am unable to explode comma separated data array from the database in codeigniter framework. I want to echo the array into multiple rows with string value like:



---------------
Product Name
---------------
Product 1
Product 2
Product 3



But i am getting array to string conversion error.



<?php foreach ($res as $key => $value) ?>
<tr class="border-bottom">
<td>
<?php $prodArray = $value->product;
echo explode(',',$prodArray) ?>
</td>
</tr>
<?php ?>


So, how can i explode and fetch the data in codeigniter







php codeigniter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 23 at 11:56









Muhammad AhtshamMuhammad Ahtsham

21




21












  • are you facing any error?

    – M.Hemant
    Mar 23 at 11:58











  • echo explode(',',$prodArray) this line is just wrong. You can't echo an array like this.

    – Eduardo Junior
    Mar 23 at 12:02












  • Please, post a $res array format example.

    – Eduardo Junior
    Mar 23 at 12:03












  • You can convert an array to a string: $arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;

    – Jamie_D
    Mar 23 at 12:23

















  • are you facing any error?

    – M.Hemant
    Mar 23 at 11:58











  • echo explode(',',$prodArray) this line is just wrong. You can't echo an array like this.

    – Eduardo Junior
    Mar 23 at 12:02












  • Please, post a $res array format example.

    – Eduardo Junior
    Mar 23 at 12:03












  • You can convert an array to a string: $arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;

    – Jamie_D
    Mar 23 at 12:23
















are you facing any error?

– M.Hemant
Mar 23 at 11:58





are you facing any error?

– M.Hemant
Mar 23 at 11:58













echo explode(',',$prodArray) this line is just wrong. You can't echo an array like this.

– Eduardo Junior
Mar 23 at 12:02






echo explode(',',$prodArray) this line is just wrong. You can't echo an array like this.

– Eduardo Junior
Mar 23 at 12:02














Please, post a $res array format example.

– Eduardo Junior
Mar 23 at 12:03






Please, post a $res array format example.

– Eduardo Junior
Mar 23 at 12:03














You can convert an array to a string: $arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;

– Jamie_D
Mar 23 at 12:23





You can convert an array to a string: $arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;

– Jamie_D
Mar 23 at 12:23












2 Answers
2






active

oldest

votes


















1














VIEW FILE



 <table>
<th>
<td>S. NO</td>
<td>Product Name</td>
</th>
<tbody>
<?php
$no = 1;
foreach($products as $product)
?>
<tr>
<td><?php echo $no;?></td>
<td><?php echo $product->product_name;?></td> //update with your column name
</tr>
<?php
$no++;
?>
</tbody>
</table>


MODEL FILE



public function get_products()

$this->db->select('*');
$this->db->from('products_table'); //update with your table name
return $this->db->get()->result_object(); // sucess result or handle exceptiom here



CONTROLLER FILE



public function product()

$this->load->model('product'); // can be loaded in the parent::__construct(); at the begining of the controller
$this->products = $this->product->get_products();
$this->load->view('products_view');






share|improve this answer






























    0














    <?php foreach ($res as $key => $value) 
    $prodArray = $value->product;
    if($prodArray) foreach($prodArray as $product)
    ?>
    <tr class="border-bottom">
    <td>
    <?php echo $product; ?>
    </td>
    </tr>
    <?php ?>





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313476%2fhow-to-explode-comma-separated-arrays-from-database%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      VIEW FILE



       <table>
      <th>
      <td>S. NO</td>
      <td>Product Name</td>
      </th>
      <tbody>
      <?php
      $no = 1;
      foreach($products as $product)
      ?>
      <tr>
      <td><?php echo $no;?></td>
      <td><?php echo $product->product_name;?></td> //update with your column name
      </tr>
      <?php
      $no++;
      ?>
      </tbody>
      </table>


      MODEL FILE



      public function get_products()

      $this->db->select('*');
      $this->db->from('products_table'); //update with your table name
      return $this->db->get()->result_object(); // sucess result or handle exceptiom here



      CONTROLLER FILE



      public function product()

      $this->load->model('product'); // can be loaded in the parent::__construct(); at the begining of the controller
      $this->products = $this->product->get_products();
      $this->load->view('products_view');






      share|improve this answer



























        1














        VIEW FILE



         <table>
        <th>
        <td>S. NO</td>
        <td>Product Name</td>
        </th>
        <tbody>
        <?php
        $no = 1;
        foreach($products as $product)
        ?>
        <tr>
        <td><?php echo $no;?></td>
        <td><?php echo $product->product_name;?></td> //update with your column name
        </tr>
        <?php
        $no++;
        ?>
        </tbody>
        </table>


        MODEL FILE



        public function get_products()

        $this->db->select('*');
        $this->db->from('products_table'); //update with your table name
        return $this->db->get()->result_object(); // sucess result or handle exceptiom here



        CONTROLLER FILE



        public function product()

        $this->load->model('product'); // can be loaded in the parent::__construct(); at the begining of the controller
        $this->products = $this->product->get_products();
        $this->load->view('products_view');






        share|improve this answer

























          1












          1








          1







          VIEW FILE



           <table>
          <th>
          <td>S. NO</td>
          <td>Product Name</td>
          </th>
          <tbody>
          <?php
          $no = 1;
          foreach($products as $product)
          ?>
          <tr>
          <td><?php echo $no;?></td>
          <td><?php echo $product->product_name;?></td> //update with your column name
          </tr>
          <?php
          $no++;
          ?>
          </tbody>
          </table>


          MODEL FILE



          public function get_products()

          $this->db->select('*');
          $this->db->from('products_table'); //update with your table name
          return $this->db->get()->result_object(); // sucess result or handle exceptiom here



          CONTROLLER FILE



          public function product()

          $this->load->model('product'); // can be loaded in the parent::__construct(); at the begining of the controller
          $this->products = $this->product->get_products();
          $this->load->view('products_view');






          share|improve this answer













          VIEW FILE



           <table>
          <th>
          <td>S. NO</td>
          <td>Product Name</td>
          </th>
          <tbody>
          <?php
          $no = 1;
          foreach($products as $product)
          ?>
          <tr>
          <td><?php echo $no;?></td>
          <td><?php echo $product->product_name;?></td> //update with your column name
          </tr>
          <?php
          $no++;
          ?>
          </tbody>
          </table>


          MODEL FILE



          public function get_products()

          $this->db->select('*');
          $this->db->from('products_table'); //update with your table name
          return $this->db->get()->result_object(); // sucess result or handle exceptiom here



          CONTROLLER FILE



          public function product()

          $this->load->model('product'); // can be loaded in the parent::__construct(); at the begining of the controller
          $this->products = $this->product->get_products();
          $this->load->view('products_view');







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 12:22









          KrishnaKrishna

          414




          414























              0














              <?php foreach ($res as $key => $value) 
              $prodArray = $value->product;
              if($prodArray) foreach($prodArray as $product)
              ?>
              <tr class="border-bottom">
              <td>
              <?php echo $product; ?>
              </td>
              </tr>
              <?php ?>





              share|improve this answer



























                0














                <?php foreach ($res as $key => $value) 
                $prodArray = $value->product;
                if($prodArray) foreach($prodArray as $product)
                ?>
                <tr class="border-bottom">
                <td>
                <?php echo $product; ?>
                </td>
                </tr>
                <?php ?>





                share|improve this answer

























                  0












                  0








                  0







                  <?php foreach ($res as $key => $value) 
                  $prodArray = $value->product;
                  if($prodArray) foreach($prodArray as $product)
                  ?>
                  <tr class="border-bottom">
                  <td>
                  <?php echo $product; ?>
                  </td>
                  </tr>
                  <?php ?>





                  share|improve this answer













                  <?php foreach ($res as $key => $value) 
                  $prodArray = $value->product;
                  if($prodArray) foreach($prodArray as $product)
                  ?>
                  <tr class="border-bottom">
                  <td>
                  <?php echo $product; ?>
                  </td>
                  </tr>
                  <?php ?>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 23 at 13:10









                  Harshwardhan SharmaHarshwardhan Sharma

                  1459




                  1459



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313476%2fhow-to-explode-comma-separated-arrays-from-database%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현