php - Is there a way to remove two numbers not affecting others? -


the code giving following output , each time, give different output.

is there way remove 2 numbers example 15 , 60, other numbers not effected remain same?

i have tried not desired result.

any or idea how this?

<?php  $arr = array();  ($i = 1; $i < 82; $i++) {     $arr[] = $i; }  shuffle($arr); $lines = array_chunk($arr, 9);  echo "<table>";  foreach ($lines $key => $line) {     echo "<tr>";     ($i = 0; $i < sizeof($line); $i++) {         echo "<td align='right'>" . $line[$i] . "</td>";     }     echo "</tr>"; }  echo "</table>"; ?>      out put   52 67  5   44  76  49  1   27  28  73 33  19  66  4   14  63  45  62  26 75  50  80  70  38  12  54  78  9  69  36  32  2   7   56  11  51  40 20  22  15  60  65  31  41  77  57 29  34  79  68  23  18  71  39  42 10  72  17  81  30  35  48  47  37 59  53  6   3   55  13  46  58  61 25  24  64  74  43  21  8   16 

this should work you:

just place code before shuffle() call. first create array of patterns, looping through numbers, want extract list, array_map().

the pattern has 2 anchors match numbers in array , not partially (e.g. 2 not match 24, match 2).

with created pattern array use preg_replace() replace numbers in array empty string.

$numbers = [15, 60]; $pattern = array_map(function($v){     return "/^$v$/"; }, $numbers); $arr = preg_replace($pattern, "", $arr); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -