fork download
  1. <?php
  2.  
  3. function buildCodeHtml($name, $model, $marca, $stock) {
  4. $html = <<<HTML
  5.  
  6.   <div class="form-group">
  7.   <label>{$name['label']}</label>
  8.   <input type="text" class="form-control" placeholder="{$name['placeholder']}" required maxlength="30" name="{$name['name']}">
  9.   </div>
  10.  
  11.   <div class="form-group">
  12.   <label>{$model['label']}</label>
  13.   <input type="text" class="form-control" placeholder="{$model['placeholder']}" required maxlength="30" name="{$model['name']}">
  14.   </div>
  15.  
  16.   <div class="form-group">
  17.   <label>{$marca['label']}</label>
  18.   <input type="text" class="form-control" placeholder="{$marca['placeholder']}" required maxlength="30" name="{$marca['name']}">
  19.   </div>
  20.  
  21.   <div class="form-group">
  22.   <label>{$stock['label']}</label>
  23.   <input type="text" class="form-control" placeholder="{$stock['placeholder']}" required maxlength="20" pattern="[0-9]{1,20}" name="{$stock['name']}">
  24.   </div>
  25.  
  26.   <hr />
  27. HTML;
  28.  
  29. return $html;
  30. }
  31.  
  32. /* Imprime */
  33. echo buildCodeHtml([
  34. "name" => "name2",
  35. "label" => "Label Nome - 2",
  36. "placeholder" => "Placeholder Nome - 2",
  37. ], [
  38. "name" => "model2",
  39. "label" => "Label Model - 2",
  40. "placeholder" => "Placeholder Model - 2",
  41. ], [
  42. "name" => "marca2",
  43. "label" => "Label Marca - 2",
  44. "placeholder" => "Placeholder Marca - 2",
  45. ], [
  46. "name" => "stock2",
  47. "label" => "Label Stock - 2",
  48. "placeholder" => "Placeholder Stock - 2",
  49. ]);
  50.  
  51.  
  52. /* Imprime */
  53. echo buildCodeHtml([
  54. "name" => "name3",
  55. "label" => "AAAAAAAAAAA",
  56. "placeholder" => "BBBBBBBBBBB",
  57. ], [
  58. "name" => "model3",
  59. "label" => "CCCCCCCCCCC",
  60. "placeholder" => "DDDDDDDDDDD",
  61. ], [
  62. "name" => "marca3",
  63. "label" => "EEEEEEEEEEE",
  64. "placeholder" => "EEEEEEEEEEE",
  65. ], [
  66. "name" => "stock3",
  67. "label" => "DDDDDDDDDDD",
  68. "placeholder" => "EEEEEEEEEEE",
  69. ]);
Success #stdin #stdout 0.02s 23532KB
stdin
Standard input is empty
stdout
    
    <div class="form-group">
       <label>Label Nome - 2</label>
       <input type="text" class="form-control"  placeholder="Placeholder Nome - 2" required maxlength="30" name="name2">
    </div>

    <div class="form-group">
       <label>Label Model - 2</label>
       <input type="text" class="form-control"  placeholder="Placeholder Model - 2" required maxlength="30" name="model2">
    </div>

    <div class="form-group">
       <label>Label Marca - 2</label>
       <input type="text" class="form-control"  placeholder="Placeholder Marca - 2" required maxlength="30" name="marca2">
    </div>

    <div class="form-group">
       <label>Label Stock - 2</label>
       <input type="text" class="form-control"  placeholder="Placeholder Stock - 2" required maxlength="20" pattern="[0-9]{1,20}" name="stock2">
    </div>
    
    <hr />    
    <div class="form-group">
       <label>AAAAAAAAAAA</label>
       <input type="text" class="form-control"  placeholder="BBBBBBBBBBB" required maxlength="30" name="name3">
    </div>

    <div class="form-group">
       <label>CCCCCCCCCCC</label>
       <input type="text" class="form-control"  placeholder="DDDDDDDDDDD" required maxlength="30" name="model3">
    </div>

    <div class="form-group">
       <label>EEEEEEEEEEE</label>
       <input type="text" class="form-control"  placeholder="EEEEEEEEEEE" required maxlength="30" name="marca3">
    </div>

    <div class="form-group">
       <label>DDDDDDDDDDD</label>
       <input type="text" class="form-control"  placeholder="EEEEEEEEEEE" required maxlength="20" pattern="[0-9]{1,20}" name="stock3">
    </div>
    
    <hr />