0

Hey there...Well I am using checkboxes to post the multi-dim array; but the thing is When I retrieve & explode it directly ,It shows an error

Warning: explode() expects parameter 2 to be string, array given in C:\ms4w\Apache\htdocs\test24.php on line 12 NULL

So If I do use 'for loop' to take one array at a time from the clicked checkboxes & then explode; It works.. but thats the problem, I dont want a single dimension arrays as the output.. I want the output to be the multi dimensional array format; the same way how I assigned them to the checkboxes

I was hoping sumone might checkout the code below & letme know How can I explode & still retain the multidimensional array?!!

thanks,

<?php

      session_start();

      if(isset($_REQUEST['submit']))//---- form is submitted -----
      {

      $tab = $_REQUEST['tab'];

var_dump ($tab);
      
      $extent = explode("::",$tab);      //Direct Explode

var_dump ($extent);

    for($i=0;$i<count($tab);$i++)
 
   {
    

    $extent = explode("::",$tab[$i]);  //Single arrays
      //echo '<br>'.$tab[$i]." is checked.";

var_dump ($extent);
     }

      }

      ?>

       

      <html>

      <form method="POST" name="myform2" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 
      <?php $table = array(
 
     
 
      array(1,'XYZ',13.59,94,06.73,92.53),
      array(2,'YZX', 19.87,84.78,12.59,76.45),
      array(3,'XZY',24.72,74.55,20.15,68.35),
      array(4,'YXZ' ,12.75,77.37,08.18,74.86),
      array(5,'ZYX' ,32.46,76.93,29.53,73.87),
 
      );
  
      ?>
  
       

      <? for($i=0;$i<count($table);$i++){?>
  
      <br><input name="tab[]" type="checkbox" value="<?=$table[$i][0]?>::<?=$table[$i][1]?>::<?=$table[$i][2]?>::<?=$table[$i][3]?>::<?=$table[$i][4]?>::<?=$table[$i][5]?>">
  
      Id : <?=$table[$i][0]?>, Name : <?=$table[$i][1]?>
 
      <? } ?>
 
      <br><br><input name="submit" value="submit" type="submit">
  
      </form>
  
      </html>

Edited by mani2604: n/a

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by hielo
0

tab is already an array. If you want to see everything as a single string then you need implode() not explode()

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.