如何重复数组和字符串

时间:2016-01-23 05:11:45

标签: arrays string repeat

如何重复数组和字符串:

$name = array (ade, ian, yasin);
$title = 'IT';

如何重复以使结果如下?

  • ade IT
  • ian IT
  • yasin IT

感谢

1 个答案:

答案 0 :(得分:0)

解决问题

    <form method="post" action="#">
    isi :<input type="text" name="isi">
    title :<input type="text" name="title">
    <table>
      <tr>
        <td><input type="text" name="name[]"></td>
      </tr>
      <tr>
        <td><input type="text" name="name[]"></td>
      </tr>
      <tr>
        <td><input type="text" name="name[]"></td>
      </tr>
      <tr>
        <td><input type="text" name="name[]"></td>
      </tr>
      <tr>
        <td><input type="text" name="name[]"></td>
     </tr>
  </table>
  <input type="submit" value="submit">
  </form>
<?php
  $rowCount = count($_POST['name']);
  $record=array();
  for ($i=0; $i<$rowCount;$i++)
  {
  $record[]=array(
    'nama' => $_POST['name'][$i],
    'isi' => $_POST['isi'],
    'title' =>$_POST['title']
    );
  }
  foreach ($record as $key => $a)
  {
  echo "".$a['nama'] ." ". $a['isi']." ".$a['title']."<br>";
  }

?>