在数组中插入新元素

时间:2016-10-21 13:07:41

标签: php

EDITED

$queryPremium ="Select * from tablename where premium = 1 order by id desc";
$rowPremium = mysql_query($queryPremium);

$queryNotPremium ="Select * from tablename where premium = 0 order by id desc";
$rowNotPremium = mysql_query($queryNotPremium);

现在我想要一个单独的数组,其中rowNotPremium的顺序将被维护,$ rowPremium将在$ rowNotPremium的2个数据之后或$ rowNotPremium的3data之后随机插入...

怎么做?

3 个答案:

答案 0 :(得分:0)

你可以这样做:

$newArray = array_merge($nonpremium, $premium)

df %>% lm(count~trt1:trt2-1, .) %>% .$coef
#### trt1far:trt2A trt1near:trt2A  trt1far:trt2B trt1near:trt2B 
####      4.000000       4.333333       4.000000       4.666667 

答案 1 :(得分:0)

如果您觉得可以编辑,请在此处编辑,请注意任何不良做法...

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header>
  <div id="main-head">
    <a href="#"><h2 id="main-heading">sKoolBook</h2></a>
  </div>
</header>
<section>
  <div id="container">
    <div id="wrapper">
      <script type="text/javascript">
        var dataCap = document.getElementById("chooseSchool").value;
        document.write(dataCap);
      </script>
      <form method="POST" id="chooseSchool">

      </form>
    </div>
  </div>
</section>
<footer>
</footer>
<p id="demo"></p>

答案 2 :(得分:0)

使用array_splice()rand()函数

$array1 = array( 1,2,3,4,5 );
$array2 = array( 6,7,8,9 ); 
array_splice( $array1, rand(0,count($array2)-1), 0, $array2 ); // splice in at random position