name属性相同的两个个select2标签值合并到一个数组里了 如何获取每一个name对应标签的值 20C

前端页面图片

图片说明

后台代码图片
图片说明

js代码

 // 显示修改关键字症状界面
function updateView(id, system_id) {
    $("#btntype").val(1);

    $("#Submit1").click(function() {
        add(1);

    });

    $
            .ajax({
                type : "POST",
                url : "/erzhentang/manage/forAjax.do?requestType=12.1",
                data : "id=" + id + "&system_id=" + system_id, // 发送到服务器的数据默认id是结论id
                success : function(msg) {
                    $("#xuewei_id").val("1,2,3").select2();
                    /* alert(msg); */
                    var json = eval('(' + msg + ')');
                    document.getElementById("addModel").style.display = "block";
                    document.getElementById("id1").value = json.earScanJielun.id;
                    document.getElementById("system_id1").value = json.earScanJielun.system_id;
                    /* 遍历所属系统下所有 耳穴频扫疾病项 */
                    var arrESJ = eval(json.listEarScanJibing);// arrESJ是一个数组
                    var checkESJ = document.getElementById("jibing_num1");
                    var str2 = "";
                    for (var j = 0; j < arrESJ.length; j++) {
                        str2 += "<option value=\"" + arrESJ[j].jibing_num
                                + "\">" + arrESJ[j].name + "</option>";
                        var checkESJ2 = arrESJ[j].name;
                        if (arrESJ[j].jibing_num == json.earScanJielun.jibing_num) {// 疾病编号人为控制每个编号都是唯一
                            arrESJ[j].name = "selected='selected'";
                        }
                        $("#jibing_num1").html(str2);
                    }
                    document.getElementById("jibing_num1").value = json.earScanJielun.jibing_num;
                    document.getElementById("jielun_rank1").value = json.earScanJielun.jielun_rank;
                    document.getElementById("jielun1").value = json.earScanJielun.jielun;
                    /* 下半截部分组合表动态展示修改和添加 */
                    var arrESC = eval(json.listEarScanCp);// arrESC是一个数组频扫结论组合表
                    var str = "";
                    var str1 = "";
                    for (var i = 0; i < arrESC.length; i++) {
                        str += "<tr>";
                        str += "<td colspan=\"8\">";
                        str += "<div style=\"margin-left: 148px;\" id=\"earScanCp\">";
                        str += "<div style=\"float: left;\">";
                        str += "<textarea style=\"width: 50px;margin-left: -86px;position: absolute;\" id=\"cp_id\" name=\"cp_id\" >"
                                + arrESC[i].id + "</textarea>";
                        str += "<select style=\"width: 60px;height: 36px;margin-left: 20px;\" id=\"gender\" name=\"gender\" >"
                        var myselect = document.getElementById("gender");// 这个获取的是静态jsp页面里标签
                        /*
                         * 下拉框主要是应展示项和所有下拉选项的值判断是否对应 分清主和客
                         * 所有展示项目为主表客表的某一项值和遍历主表的值对应 这里面 下拉框所有选项值是主表
                         */
                        var str1 = "";
                        for (var j = 0; j < myselect.options.length; j++) {// 下拉框是主家从静态页面获取并且遍历它
                            // alert("j值:" + myselect.options[j].value);
                            str += "<option value=\""
                                    + myselect.options[j].value
                                    + "\" "
                                    + (myselect.options[j].value == arrESC[i].gender ? "selected='selected'"
                                            : "") + ">"
                                    + myselect.options[j].text + "</option>";
                        }
                        "</select>";
                        str += "<textarea style=\"width: 50px;margin-left: 10px;\" id=\"min_age\" name=\"min_age\" >"
                                + arrESC[i].min_age + "</textarea>";
                        str += "<textarea style=\"width: 50px;margin-left: 10px;\" id=\"max_age\" name=\"max_age\" >"
                                + arrESC[i].max_age + "</textarea>";
                        // str += "<textarea style=\"width:
                        // 300px;margin-left:10px;\" id=\"xuewei_id\"
                        // name=\"xuewei_id\" >"
                        // + arrESC[i].xuewei_id + "</textarea>";
                        // str +="<div id=\"selectSection\">";
                        /*
                         * id=\"xuewei_id\"
                         */
                        str += "<textarea  style=\"width:300px;margin-left:10px;display:none;\" id=\"xuewei_id1\" name=\"xuewei_id1\" >"
                                + arrESC[i].xuewei_id + "</textarea>";
//                      str += "<div id=\"selectSection\" name=\"selectSection\">";
                        str += "<select style=\"width: 300px;margin-left:10px;\"  name=\"xuewei_id\"class=\"combox\" multiple >"
                        str += "<optgroup label=\"小辈儿组\">";
                        str += "<option value=\"1\" " + "selected='selected'"
                                + ">心</option>";
                        str += "<option value=\"2\" " + "selected='selected'"
                                + ">" + "肺" + "</option>";
                        str += "<option value=\"3\" " + "selected='selected'"
                                + ">" + "小肠" + "</option>";
                        str += "<option value=\"4\">" + "口" + "</option>";
                        str += "<option value=\"5\">" + "食道" + "</option>";
                        str += "</optgroup>";
                        // str += "</div>";
                        /* 进一步转换频扫组合表穴位id字符串转array数组 */

                        /*
                         * var strXueweiId = arrESC[i].xuewei_id; var
                         * arrayXueweiId = strXueweiId.split(",");
                         * 
                         * for (var j = 0; j < arrayXueweiId.length; j++) { str2 += "<option
                         * value=\"" + arrayXueweiId[j].value + "\">" +
                         * arrayXueweiId[j].value + "</option>"; var checkESJ2 =
                         * arrayXueweiId[j].name; if (arrayXueweiId[j] == 5) {
                         * arrayXueweiId[j] = "selected='selected'"; }
                         * $("#jibing_num1").html(str2); }
                         */
                        "</select>";
                        //
                        // $("#xuewei_id").val("1,2,3").select2();

                        str += "<textarea style=\"width: 220px;margin-left: 10px;\" id=\"chuzhen_id\" name=\"chuzhen_id\" >"
                                + arrESC[i].chuzhen_id + "</textarea>";
                        str += "<select style=\"width: 60px;height: 36px;margin-left: 10px;\" id=\"bp\" name=\"bp\" >"
                        var myselect1 = document.getElementById("bp");// 这个获取的是静态jsp页面里标签
                        for (var k = 0; k < myselect1.options.length; k++) {// 下拉框是主家从静态页面获取并且遍历它
                            // alert("j值:" + myselect1.options[k].value);
                            str += "<option value=\""
                                    + myselect1.options[k].value
                                    + "\" "
                                    + (myselect1.options[k].value == arrESC[i].bp ? "selected='selected'"
                                            : "") + ">"
                                    + myselect1.options[k].text + "</option>";
                        }
                        "</select>";
                        str += "<textarea style=\"width: 50px; height: 36px;margin-left: 10px;margin-top: 0px;\" id=\"jielun_conform\" name=\"jielun_conform\">"
                                + arrESC[i].jielun_conform + "</textarea>";
                        str += "</div>";
                        str += "<div >";
                        str += " <input type=\"button\" onclick=\"delRow(this,"
                                + arrESC[i].id
                                + ","
                                + arrESC[i].bianzhengId
                                + ")\" value=\"删除\" id=\"deleteESC\" name=\"deleteESC\" style=\"float: left; margin-left:10px; margin-top: 5px;\">";
                        str += "</div>";
                        str += "</div>";
                        str += "</td>";
                        str += "</tr>";
                        /* 替换静态页面 */
                        $("#tbody1").html(str);

                        select2Execute();
                    }

                }
            });
}

执行select2方法

 /* 执行select2方法 */
function select2Execute() {

    $(function() {

        $("select[name='xuewei_id']").select2({
            // $('select[id="xuewei_id"]').select2({
            // $('#xuewei_id').select2({
            // $("#selectSection").find("select.combox").select2({
            // $(".select2-selection__choice").select2();
            // $(".combox").select2({

            placeholder : "请至少选择一个人名",
            tags : true,
            createTag : function(decorated, params) {
                return null;
            },
            width : '256px'
        });

        function formatState(state) {
            if (!state.id) {
                return state.text;
            }
            var $state = $('<span>' + state.text + '</span>');
            return $state;
        }
        ;

        $('#sel_recommender').select2({
            placeholder : "请选择一个人名",
            templateResult : formatState,
            width : '256px'
        });
        alert($("select[name='xuewei_id']").select2('data')[0].text);

        // $("#selectSection").find("select.xuewei_id").val();
        // document.getElementById("selectSection").value=$("select[name='xuewei_id']").select2('data');
        $("#xuewei_id1").val(
                $("select[name='xuewei_id']").select2('data'));//赋值给textarea隐藏的标签
        alert($("#xuewei_id1").val());
    });
}

4个回答

u012503756
bulidfer alert(document.querySelectorAll('*[name="xuewei_id"]'));一下得到的结果是[object NodeList]
接近 2 年之前 回复
    <script>
        $(function(){
            var m1 = $('select[name="mm"]')[0].value;
            var m2 = $('select[name="mm"]')[1].value;
            console.log(m1,m2);
        })
    </script>

                <select name="mm">
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
    </select>
    <select name="mm">
        <option>5</option>
        <option>6</option>
        <option>7</option>
        <option>8</option>
    </select>

    按这个方法试试  因为有两个 js  查出来 会组成一个数组   在数组中去找对应的  两个select   [0]代表第一个  [1]代表第二个 

    希望 能帮助到你
qq_33919053
仰望sky 是select 不是 js 打字失误
接近 2 年之前 回复
$(function(){ var m1 = $("select[name-re='1']").val(); var m2 = $("select[name-re='2']").val(); console.log(m1,m2); })
            <select name-re="1" name="mm">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
</select>
<select name-re="2"  name="mm">
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
</select>
 $(function(){ var m1 = $("select[name-re='1']").val(); var m2 = $("select[name-re='2']").val(); console.log(m1,m2); })
            <select name-re="1" name="mm">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
</select>
<select name-re="2"  name="mm">
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
</select>
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
select2 多选下拉框的选项 重复 当选中的值为多选项 str拼接做了两次for循环

如何用jquery 实行对 select选中赋值 且不重复拼接 option ![图片说明](https://img-ask.csdn.net/upload/201808/06/1533563305_984956.png) 用了第二个方法 但是 不会回显 ![图片说明](https://img-ask.csdn.net/upload/201808/06/1533564365_779881.png) js代码 ``` var arrESC = eval(json.listEarScanCp);// arrESC是一个数组频扫结论组合表 var arrESA = eval(json.listEarScanAcupoint);// arrESA是一个科研穴位信息 var str = ""; var str1 = ""; for (var i = 0; i < arrESC.length; i++) { str += "<tr>"; str += "<td colspan=\"8\">"; str += "<div style=\"margin-left: 148px;\" id=\"earScanCp\">"; str += "<div style=\"float: left;\">"; str += "<textarea style=\"width: 50px;margin-left: -86px;position: absolute;\" id=\"cp_id\" name=\"cp_id\" >" + arrESC[i].id + "</textarea>"; str += "<select style=\"width: 60px;height: 36px;margin-left: 20px;\" id=\"gender\" name=\"gender\" >" var myselect = document.getElementById("gender");// 这个获取的是静态jsp页面里标签 /* * 下拉框主要是应展示项和所有下拉选项的值判断是否对应 分清主和客 * 所有展示项目为主表客表的某一项值和遍历主表的值对应 这里面 下拉框所有选项值是主表 */ var str1 = ""; for (var j = 0; j < myselect.options.length; j++) {// 下拉框是主家从静态页面获取并且遍历它 // alert("j值:" + myselect.options[j].value); str += "<option value=\"" + myselect.options[j].value + "\" " + (myselect.options[j].value == arrESC[i].gender ? "selected='selected'" : "") + ">" + myselect.options[j].text + "</option>"; } "</select>"; str += "<textarea style=\"width: 50px;margin-left: 10px;\" id=\"min_age\" name=\"min_age\" >" + arrESC[i].min_age + "</textarea>"; str += "<textarea style=\"width: 50px;margin-left: 10px;\" id=\"max_age\" name=\"max_age\" >" + arrESC[i].max_age + "</textarea>"; /* select2标签开始 */ str += "<textarea style=\"width:300px;margin-left:10px;display:none;\" id=\"strXueweiId\" name=\"strXueweiId\" >" + arrESC[i].xuewei_id + "</textarea>"; str += "<select name=\"xuewei_id\" class=\"form-control input-sm downList2\" multiple>"; alert("arrESA.length值:" + arrESA.length); // 将arrESC[i].xuewei_id分割成一个数组 var arrXueweId = arrESC[i].xuewei_id.split(","); alert("arrXueweId:" + arrXueweId) for (var j = 0; j < arrESA.length; j++) {// 下拉框是主家从静态页面获取并且遍历它 for (var k = 0; k < arrXueweId.length; k++) { str += "<option value=\"" + arrESA[j].id + "\" " + (arrESA[j].id == arrXueweId[k] ? "selected='selected'" : "") + ">" + arrESA[j].text + "</option>"; } } "</select>"; ``` 执行select2部分 ``` function select2Execute() { $(function() { /* 1-本地注入方式 */ $(".downList2").select2({ // $("select[name='xuewei_id']").select2({ // $('select[id="xuewei_id"]').select2({ // $('#xuewei_id').select2({ placeholder : "请至少选择一个人名", tags : true, createTag : function(decorated, params) { return null; }, width : '256px', }); function formatState(state) { if (!state.id) { return state.text; } var $state = $('<span>' + state.text + '</span>'); return $state; } ; $('#sel_recommender').select2({ placeholder : "请选择一个人名", templateResult : formatState, width : '256px' }); // 通过id获取select2的text值,这里的text值可能有空格,需注意 function getSelect2Text(obj) { var select2Obj = $("select[name='xuewei_id']").select2(); return select2Obj.find("option:selected").text(); } /* 获取每一个name对应的值 */ var strXueweiId = ""; $("[name=xuewei_id]").each(function() { alert("this值:" + $(this).val()); /* 拼接每一项name的值 组合成和其它项目类似 gender那样的数组 */ strXueweiId += $(this).val() + "-"; }); alert("strXueweiId:" + strXueweiId) $("#strXueweiId").val(strXueweiId) }); } ```

数组合并和删除重复值

<div class="post-text" itemprop="text"> <p>I have this foreach loop that outputs the below array, and I'm having a senior moment, I need it to return one array with no duplicate values, and I just can't it right.</p> <pre><code>foreach ( $post_groups as $post_group =&gt; $id ) { group = $wpdb-&gt;get_row( $wpdb-&gt;prepare("SELECT * FROM $table_name WHERE ID = %d", $id), ARRAY_A); $groups[$group['group_name']] = $group['group_name'] = unserialize( $group['group_users'] ); } </code></pre> <p>output:</p> <pre><code>array(2) { ["Registered Users"]=&gt; array(1) { [0]=&gt; string(1) "2" } ["Admin Users"]=&gt; array(2) { [0]=&gt; string(1) "1" [1]=&gt; string(1) "2" } } </code></pre> <p>Cheers</p> </div>

合并两个数组并循环遍历它们以返回所有元素

<div class="post-text" itemprop="text"> <p>I have two queries that return 5 rows of data from each query. I then merge the resulting arrays to create one array.</p> <p>If I were using just one arry I would do it like this:</p> <pre><code>mysql_select_db($database_iMaint, $iMaint); $query_WaterHot = sprintf("SELECT h.UniqueID, h.Room, h.AuditBy, h.AuditDate, h.SeqID, h.WaterHot FROM NXLHR_Hist h WHERE (h.WaterHot IS NOT NULL OR h.WaterHot IS NOT NULL ) AND h.CompStamp &gt;= DATE('".$_POST['FromDate']."') AND h.CompStamp &lt;= DATE('".$_POST['ToDate']."') ORDER BY h.Room ASC "); $WaterHot = mysql_query($query_WaterHot, $iMaint) or die(mysql_error()); $row_WaterHot = mysql_fetch_assoc($WaterHot); $totalRows_WaterHot= mysql_num_rows($WaterHot); do { echo $row_WaterHot['Room']; echo $row_WaterHot['WaterHot']; echo $row_WaterHot['WaterCold']; } while ($row_WaterHot = mysql_fetch_assoc($WaterHot)); </code></pre> <p>Above is how I would normally process the data but in this case I am using the results from two queries which is why I am merging them.</p> <p>So I now need to loop through the merged array and output each of the values.</p> <pre><code>$row_WaterHot = mysql_fetch_assoc($Waterhot); // five records $row_WaterCold = mysql_fetch_assoc($WaterCold); // five records $Water = array(); $Water = array_merge($row_WaterHot, $row_WaterCold); foreach ($Water as $key =&gt; $value) { // how do I echo the results of each value like this echo "the name of the $key and the $value } </code></pre> <p>Or should I be doing this another way?</p> <p>Thanks in advance for your help and time.</p> </div>

在php中合并多个数组

<div class="post-text" itemprop="text"> <p>Here is a sample array values that is returning:</p> <p>Here is the first array:</p> <pre><code>Array 1: 0 =&gt; name =&gt; Test name value desrciption =&gt; Test description value category =&gt; Test category value code_1 =&gt; IGEF001 code_2 =&gt; IGGF001 1 =&gt; name =&gt; Test name value desrciption =&gt; Test description value category =&gt; Test category value code_1 =&gt; IGEF003 code_2 =&gt; IGGF003 2 =&gt; name =&gt; Test name value desrciption =&gt; Test description value category =&gt; Test category value code_1 =&gt; IGEF004 code_2 =&gt; IGGF004 </code></pre> <p>Here is the second array:</p> <pre><code>Array 2: 0 =&gt; return_code =&gt; IGEF003 1 =&gt; return_code =&gt; IGGF003 2 =&gt; return_code =&gt; IGGF004 3 =&gt; return_code =&gt; IGEF004 4 =&gt; return_code =&gt; IGGF001 5 =&gt; return_code =&gt; IGEF001 </code></pre> <p>Here is what I'm trying to accomplish: </p> <pre><code> 0 =&gt; name =&gt; Test name value desrciption =&gt; Test description value category =&gt; Test category value code_1 =&gt; IGEF001 code_2 =&gt; IGGF001 select_code_1 =&gt; IGEF001 &lt;-- Value coming from the second array select_code_2 =&gt; IGGF001 &lt;-- Value coming from the second array 1 =&gt; name =&gt; Test name value desrciption =&gt; Test description value category =&gt; Test category value code_1 =&gt; IGEF003 code_2 =&gt; IGGF003 select_code_1 =&gt; IGEF003 &lt;-- Value coming from the second array select_code_2 =&gt; IGGF003 &lt;-- Value coming from the second array 2 =&gt; name =&gt; Test name value desrciption =&gt; Test description value category =&gt; Test category value code_1 =&gt; IGEF004 code_2 =&gt; IGGF004 select_code_1 =&gt; IGEF004 &lt;-- Value coming from the second array select_code_2 =&gt; IGGF004 &lt;-- Value coming from the second array </code></pre> <p>I hope this is enough information, let me know if you need any more.</p> </div>

PHP - 如何将两个不同的JSON输出合并为一个

<div class="post-text" itemprop="text"> <h2>My php server is generating two JSON output</h2> <p>1.] For MySql JSON printing I am using this code.</p> <pre><code>$sql = "select id ,Title , Meassage from lodhinews"; $result = $conn-&gt;query($sql); $values = array(); if ($result-&gt;num_rows &gt; 0) { // output data of each row while($row = $result-&gt;fetch_assoc()) { $values['data'][] = array( 'id'=&gt;$row['id'], 'Title'=&gt;$row['Title'], 'Meassage'=&gt;$row['Meassage'] ); } header('Content-Type: application/json;charset=utf-8'); echo json_encode($values ,JSON_PRETTY_PRINT); } else { $values = array( 'error'=&gt;'No results found' ); } $conn-&gt;close(); ?&gt; </code></pre> <p>2.] For file name printing I am using this code </p><pre><code>chdir('./uploads'); foreach(glob('*.*') as $filename){ $data[] = $filename; } echo json_encode($data); ?&gt; </code></pre> <p>both the above code is working fine!</p> <p><strong>I wanted this both json output combined on one single page</strong></p> </div>

如何使用laravel将两个对象合并为一个对象

<div class="post-text" itemprop="text"> <p>I am getting objects response like this:</p> <pre><code> "facilities": [ [ { "facility_id": 1, "speciality_id": null, "is_facility_supervisor": 0, "priv_key": "can_add_doctor,can_view_doctor" } ], { "name": "Patient", "role_id": 7 } ] </code></pre> <p>I want name and role_id into facilities and i want expected output like this</p> <pre><code> "facilities": [ [ { "facility_id": 1, "speciality_id": null, "is_facility_supervisor": 0, "priv_key": "can_add_doctor,can_view_doctor", "name": "Patient", "role_id": 7 } ], ] </code></pre> <p>How i can achieve this output name and role_id is in separate object but i want in one object like i shared.</p> <p>My Code:</p> <pre><code>$specialities = DB::table('user_facility') -&gt;select('user_facility.facility_id','user_facility.speciality_id','user_facility.is_facility_supervisor','user_facility.priv_key') -&gt;where('user_id',$currentUser-&gt;id)-&gt;get(); $roles = DB::table('roles') -&gt;join('user_facility', 'roles.id', 'user_facility.role_id') -&gt;where('user_facility.user_id', Auth::user()-&gt;id) -&gt;select('roles.name','user_facility.role_id')-&gt;first(); $superadmin = $is_super_admin-&gt;is_super_admin; $specialities = (object) $speciality_id; $response = ['is_super_admin' =&gt; $superadmin, 'facilities' =&gt; array_merge([$specialities,$roles])]; </code></pre> <p>Your help will be highly appreciated?</p> </div>

c#中输出多个sql查询的值

SqlCommand cmd = new SqlCommand("select NAME FROM TREE1 WHERE OBJECT = (SELECT ID FROM TREE1 WHERE NAME = '" + textBox1.Text + "')", conn); 这句查询语句中,应该得到多个name的值,我要怎么才能在richtextbox全部显示出来呢,菜鸟一枚,求大神指教,这个表是树形结构存储生成的,有ID,name 和指向ID的列,一共三列!!!急急急

PHP - 合并超过2个数组

<div class="post-text" itemprop="text"> <p>I'm trying to make the values in the <code>EVENTNAME</code> array the key of the arrays below it. </p> <p>I want to be able to do a foreach on on a php variable and get the <code>EVENTNAME</code> and the count for its IMMIGRATIONS, EFFECTS and SUPPLYCHAINS.</p> <pre><code>$keyevents = oci_parse($conn, "SELECT EVENTNAME FROM KEYEVENTS GROUP BY EVENTNAME"); oci_execute($keyevents); oci_fetch_all($keyevents, $keyevent); $immigrations = oci_parse($conn, "SELECT COUNT(*) IMMIGRATIONS FROM KEYEVENTS LEFT JOIN IMMIGRATION ON KEYEVENTS.EVENTID = IMMIGRATION.EVENTID GROUP BY EVENTNAME"); oci_execute($immigrations); oci_fetch_all($immigrations, $imm); $effects = oci_parse($conn, "SELECT COUNT(*) EFFECTS FROM KEYEVENTS LEFT JOIN EFFECT ON KEYEVENTS.EVENTID = EFFECT.EVENTID GROUP BY EVENTNAME"); oci_execute($effects); oci_fetch_all($effects, $eff); $supplychains = oci_parse($conn, "SELECT COUNT(*) SUPPLYCHAINS FROM KEYEVENTS LEFT JOIN SUPPLYCHAINS ON KEYEVENTS.EVENTID = SUPPLYCHAINS.EVENTID GROUP BY EVENTNAME"); oci_execute($supplychains); oci_fetch_all($supplychains, $supp); $stats = array_merge($keyevent, $imm, $eff, $supp); highlight_string("&lt;?php \$stats = " . var_export($stats, true) . "; ?&gt;"); </code></pre> <p><strong>var_export</strong></p> <pre><code>array ( 'EVENTNAME' =&gt; array ( 0 =&gt; 'Brexit', 1 =&gt; 'leave date set', 2 =&gt; 'leave date ', 3 =&gt; 'deal or no deal', ), 'IMMIGRATIONS' =&gt; array ( 0 =&gt; '1', 1 =&gt; '1', 2 =&gt; '1', 3 =&gt; '1', ), 'EFFECTS' =&gt; array ( 0 =&gt; '2', 1 =&gt; '1', 2 =&gt; '1', 3 =&gt; '2', ), 'SUPPLYCHAINS' =&gt; array ( 0 =&gt; '1', 1 =&gt; '1', 2 =&gt; '1', 3 =&gt; '1', ), ) </code></pre> <p><a href="https://i.stack.imgur.com/hchEv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hchEv.png" alt="Output of $Stats"></a></p> </div>

C# 两个不相同结构的datatable中的数据只有一个主键一样如何快速比较返回差集

现在有2个表部分学校表和学校表 其中部分学校表在A库、学校表在B库 SCH_ID为关联主键 部分学校表 AUTO_ID USER_ID COTY_NO SCH_ID SCH_NO SCH_NAME 1 17 123 341289001 1 职业学院 学校表 SCH_ID SCH_NO SCH_NAME 341289001 1 职业学院 341259851 2 XX学院 现在通过数据库查询得到 DataTable SchoolA; 部分学校数据 DataTable SchoolAll;全部学校数据 SCH_ID为关联主键 现在想写个方法最快速的取出差集如XX学院(表里的数据目前就举例几天、实际5W多条) 目前自己的思路是遍历DataTable.Select()这样遍历去查询、有没有更好的方法

PHPEXCEL:如何基于数组值合并excel行

<div class="post-text" itemprop="text"> <p>this my MySQL to generate the array :</p> <pre><code>$sql_name = "SELECT * FROM ".TABLE_PREFIX."members WHERE member_id IN ($member_id) order by member_id DESC"; $result_name = mysql_query($sql_name, $db); $name = array(); while ($row = mysql_fetch_assoc($result_name)) { $arr1= $row['first_name']; $arr = array_push($name ,$arr1); } $name1[] = $name; $objPHPExcel-&gt;setActiveSheetIndex()-&gt;fromArray($name1, NULL, 'C20'); </code></pre> <p>This is the result that i get :</p> <p><img src="https://i.stack.imgur.com/tkxKO.jpg" alt="enter image description here"></p> <p><strong>Output that i want is each array will fill 2 rows means it will take next column and merge it</strong> like this below image. How can possible to use merge?.. i new to this. please help me. thanks!</p> <p><img src="https://i.stack.imgur.com/DbBSS.jpg" alt="enter image description here"></p> <p><strong>SOLUTION FOR MY QUESTION FOR REFERENCE LATER :</strong></p> <pre><code>for($row = 20; $row &lt;= 2; $row++) { $objPHPExcel-&gt;setActiveSheetIndex()-&gt;fromArray($name1, NULL, 'C20')-&gt;mergeCells('C' . $row . ':D' . $row); } </code></pre> <p>and i change my sql .. by adding empty space to the array :</p> <pre><code> $arr = array_push($name ,$arr1,''); </code></pre> </div>

我如何比较和合并两个数组

<div class="post-text" itemprop="text"> <p>I have following two arrays which comes from the same database use the same query to get both. both contains information about a single sales order having two different line items(Bill of materials) the first one has Line Item<code>ItemID= 600271</code> and the second one has LineItem <code>ItemID=600274</code> but as you can see below they both have the same Sales Order Number <code>[CustomerSONo] =&gt; [7] =&gt; **15020**</code></p> <p>so How can i compare or union these two array's. ?</p> <p>//query</p> <pre><code> $result= --select statement--; while($row = mysqli_fetch_array($result)) { print_r($row); } </code></pre> <p>Array 1</p> <pre><code> Array ( [0] =&gt; XXX001 [CustomerId] =&gt; XXX001 [1] =&gt; XXX Company Name.* [Customer_Bill_Name] =&gt; XXX Company Name.* [2] =&gt; DHE [WhichShipVia] =&gt; DHE [3] =&gt; [INV_POSOOrderNumber] =&gt; [4] =&gt; 2014-12-19 [ShipByDate] =&gt; 2014-12-19 [5] =&gt; [GoodThruDate] =&gt; [6] =&gt; [CustomerSONo] =&gt; [7] =&gt; 15020 [Reference] =&gt; 15020 [8] =&gt; 2014-11-25 [TransactionDate] =&gt; 2014-11-25 [9] =&gt; 1 [DistNumber] =&gt; 1 [10] =&gt; 70.0000000000000000000 //here is the difference 1 [Quantity] =&gt; 70.0000000000000000000 //here is the difference 2 [11] =&gt; 600271 //here is the difference 3 [ItemId] =&gt; 600271 //here is the difference 4 [12] =&gt; ASSY7.60-15SL/8 FRM I1 15X6 6-6, BLK (GWT-761508 (24) //here is the difference 5 [SalesDescription] =&gt; ASSY7.60-15SL/8 FRM I1 15X6 6-6, BLK (GWT-761508)(24)//here is the difference 1 //here is the difference 6 [13] =&gt; AS1577 //here is the difference 7 [PartNumber] =&gt; AS1577 //here is the difference 8 [14] =&gt; ASSY7.60-15 8PLY W/WHL15X6 BLK //here is the difference 9 [ItemDescription] =&gt; ASSY7.60-15 8PLY W/WHL15X6 BLK ) </code></pre> <p>Array 2:</p> <pre><code> Array ( [0] =&gt; XXX001 [CustomerId] =&gt; XXX001 [1] =&gt; XXX Company Name.* [Customer_Bill_Name] =&gt; XXX Company Name.* [2] =&gt; DHE [WhichShipVia] =&gt; DHE [3] =&gt; [INV_POSOOrderNumber] =&gt; [4] =&gt; 2014-12-19 [ShipByDate] =&gt; 2014-12-19 [5] =&gt; [GoodThruDate] =&gt; [6] =&gt; [CustomerSONo] =&gt; [7] =&gt; 15020 [Reference] =&gt; 15020 [8] =&gt; 2014-11-25 [TransactionDate] =&gt; 2014-11-25 [9] =&gt; 2 [DistNumber] =&gt; 2 [10] =&gt; 6.0000000000000000000 //here is the difference 1 [Quantity] =&gt; 6.0000000000000000000 //here is the difference 2 [11] =&gt; 600274 //here is the difference 3 [ItemId] =&gt; 600274 //here is the difference 4 [12] =&gt; ASSY9.5L-15SL/8 FLT I1 15X8 6-6, BLK (GWT-951508)(16) [SalesDescription] =&gt; ASSY9.5L-15SL/8 FLT I1 15X8 6-6, BLK (GWT-951508)(16) //here is the difference 5 [13] =&gt; AS1601 //here is the difference 6 [PartNumber] =&gt; AS1601 //here is the difference 7 [14] =&gt; ASSY9.5L-15 W/WHL15X8 6/6 BLK //here is the difference 8 [ItemDescription] =&gt; ASSY9.5L-15 W/WHL15X8 6/6 BLK ) //here is the difference 9 </code></pre> </div>

php排序合并数组

<div class="post-text" itemprop="text"> <p>I have a list of (xml) items, each item has a category and a name:</p> <h2>Category | Name</h2> <pre><code>1 | Joe 2 | Carol 3 | Bruce 1 | Michael 1 | Alan 2 | Brian </code></pre> <p>I want to sort the names ascending within categories descending like so:</p> <h2>Category | Name</h2> <pre><code>3 | Bruce 2 | Brian 2 | Carol 1 | Alan 1 | Joe 1 | Michael </code></pre> <p>with the aim of creating a Select dropdown on a web page with each category as an OptGroup and the names sorted within the OptGroup. I have very little experience with PHP, I think I need to sort merge arrays, but after many hours trying to understand how to, I'm not making much progress. Any help greatly appreciated</p> </div>

将两个数组合并为单个内部json_encode for android

<div class="post-text" itemprop="text"> <p>I have to combine two array into single inside Json encode. my code is,</p> <pre><code>// Controller $email = $this-&gt;input-&gt;get('email'); $pass = $this-&gt;input-&gt;get('password'); $enc_pass = 0; $get_pass = $this-&gt;select-&gt;selectData($email); if(!empty($get_pass)) { foreach($get_pass as $password) $enc_pass = $password['user_password']; $dec_pass = $this-&gt;encrypt-&gt;decode($enc_pass); if($pass == $dec_pass) { $details = array('tag' =&gt; 'login', 'status' =&gt; 'true'); echo json_encode(array_merge($get_pass, $details)); } else { $details = array('tag' =&gt; 'login', 'status' =&gt; 'false', 'error_msg' =&gt; 'Incorrect Email or Password'); echo json_encode($details); } } else { $details = array('tag' =&gt; 'login', 'status' =&gt; 'false', 'error_msg' =&gt; 'Incorrect Email or Password'); echo json_encode($details); } // Model public function selectData($email) { $query = $this-&gt;db-&gt;query('SELECT * FROM tbl_user WHERE email = "'.$email.'"'); $count = $query-&gt;num_rows(); if($count &gt; 0) return $result = $query-&gt;result_array(); else return 0; } </code></pre> <p>Now the output for the above code is,</p> <p><code>{"0":{"user_id":"1","user_name":"Jithin Varghese","user_email":"jithinvarghese111@gmail.com","user_phone":"9947732296","user_status":"1"},"tag":"login","status":"true"}</code></p> <p>Required output is,</p> <p><code>{"user_id":"1","user_name":"Jithin Varghese","user_email":"jithinvarghese111@gmail.com","user_phone":"9947732296","user_status":"1","tag":"login","status":"true"}</code></p> <p>How to get the required output. I have tried a lot. How to implement this.</p> <p>Thankyou.</p> </div>

PHP 二维数组分组 求和

如题; 类似 select name,sum(money) from user group by uid; 怎么弄,谢谢

如何把相同的订单号合并到一起?

/**********定单基本信息表******************/ drop table if exists sh_order; create table sh_order ( id mediumint unsigned not null auto_increment, order_sn char(16) not null comment '定单编号', member_id mediumint unsigned not null comment '会员id', addtime int unsigned not null comment '下单时间', pay_status enum("是","否") not null default '否' comment '支付状态', post_status enum("是","否") not null default '否' comment '发货状态', total_price decimal(10,2) not null comment '总价', postage decimal(10,2) not null comment '邮费', pay_time int unsigned not null default '0' comment '付款时间', pay_method enum("支付宝") not null default '支付宝' comment '支付方式', post_method enum("顺风","圆通") not null comment '配送方式', shr_name varchar(30) not null comment '收货人', shr_province varchar(30) not null comment '收货人省', shr_city varchar(30) not null comment '收货城市', shr_area varchar(30) not null comment '收货地区', shr_address varchar(150) not null comment '收货地址', shr_postcode varchar(30) not null comment '收货邮编', shr_mobile varchar(30) not null comment '收货人手机', primary key (id), key member_id(member_id), key order_sn(order_sn), key addtime(addtime) )engine=InnoDB default charset=utf8 comment '定单基本信息表'; /****************订单商品表**************************/ drop table if exists sh_order_goods; create table sh_order_goods ( id mediumint unsigned not null auto_increment, order_id mediumint unsigned not null comment '定单id', goods_id mediumint unsigned not null comment '商品id', goods_name varchar(60) not null comment '商品名称', goods_attr_id varchar(150) not null default '' comment '商品属性id', price decimal(10,2) not null comment '购买时的价格', goods_number int unsigned not null comment '购买的数量', primary key (id), key order_id(order_id), key goods_id(goods_id) )engine=InnoDB default charset=utf8 comment '定单商品表'; /**************商品表*******************/ drop table if exists sh_goods; create table sh_goods ( id mediumint unsigned not null auto_increment, sm_logo varchar(150) not null default '' comment 'logo的缩略图路径(150*150)', logo varchar(150) not null default '' comment 'logo的路径', sm_show_pic varchar(150) not null default '' comment '展示图的缩略图路径(150*150)', show_pic varchar(150) not null default '' comment '展示图的原图路径', goods_brand_id mediumint unsigned not null comment '商品品牌id', goods_name varchar(60) not null comment '商品名称', market_price decimal(10,2) not null comment '市场价', shop_price decimal(10,2) not null comment '本店价', is_on_sale enum('是','否') not null default '是' comment '是否上架', goods_number mediumint unsigned not null default '0' comment '库存量', type_id mediumint unsigned not null default '0' comment '类型id', goods_desc text comment '商品描述', order_num tinyint unsigned not null default '100' comment '排序数字', addtime int unsigned not null comment '添加时间', primary key (id), key shop_price(shop_price), key is_on_sale(is_on_sale), key addtime(addtime), key order_num(order_num) )engine=MyISAM default charset=utf8 comment '商品'; /**************商品属性表************************/ drop table if exists sh_goods_attr; create table sh_goods_attr ( id mediumint unsigned not null auto_increment, goods_id mediumint unsigned not null comment '商品id', attr_id mediumint unsigned not null comment '属性id', attr_value varchar(150) default '' not null comment '属性的值', primary key (id), key goods_id(goods_id), key attr_id(attr_id) )engine=MyISAM default charset=utf8 comment '商品属性'; // Model模型中,根据会员ID从数据库中取出会员自己的订单, public function getOrder($mid) { $orderModel = M('Order'); $orderData = $orderModel->field('a.order_sn, a.addtime, a.shr_name, c.goods_name, c.sm_logo, b.goods_number, b.price, d.attr_value, a.postage, a.post_status') ->alias('a')->join('LEFT JOIN sh_order_goods b ON a.id = b.order_id')-> join('LEFT JOIN sh_goods c ON b.goods_id = c.id')-> join('LEFT JOIN sh_goods_attr d ON b.goods_attr_id = d.id') ->where('a.member_id='.$mid)->select(); } //在Controller控制器用户中心里调用 public function center() { if(session('id')) { $mid = session('id');//session('id')就是会员ID $memberModel = D('Member/Member'); $orderData = $memberModel->getOrder($mid); $this->assign('orderData',$orderData); } else { redirect('login'); } $this->display(); } HTML页面中输出: <?php foreach($orderData as $k => $v):?> <tr> <td><?php echo $v['order_sn'];?></td> <td><?php showImage($v['sm_logo']);?></td> <td><?php echo $v['goods_name'];?></td> <td><?php echo $v['shr_name'];?></td> <td><?php echo $v['goods_number'].' * '.$v['price'].'¥'.'='.$v['goods_number']*$v['price'].'¥' ;?></td> <td><?php echo date('Y-m-d',$v['addtime']);?></td> <td><?php echo $v['post_status'];?></td> <td><a href="javascript:void(0);">取消订单</a></td> </tr> <?php endforeach;?> ![图片说明](https://img-ask.csdn.net/upload/201503/22/1426981850_621771.jpg) 怎样把订单号相同的合并起来呢,我该怎样改变数组结构呢?类似淘宝的订单 ![图片说明](https://img-ask.csdn.net/upload/201503/22/1426981890_525225.jpg)

合并/删除具有相同子键的数组

<div class="post-text" itemprop="text"> <p>I'm writing a database class for my site based on a fluent interface. First, I collect all the meaningful terms then put them into the "stack", which is basically an array. Then, I sort them in order that they would appear in an actual SQL query.</p> <pre><code>const stmt_select = 1; const stmt_insert = 2; const stmt_delete = 3; const sql_select = 10; const sql_from = 11; const sql_into = 12; const sql_where = 13; const sql_join = 14; const sql_group = 15; const sql_order = 16; const sql_limit = 17; </code></pre> <p>For example, the query below (although in a total rubbish order, and purposely trying to throw the class off):</p> <pre><code>Query::Select('name', 'age', 'height') -&gt;Order('a') -&gt;From('table') -&gt;From('asd') -&gt;Group('a') -&gt;Execute(); </code></pre> <p>.. produces:</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; 10 [1] =&gt; Array ( [0] =&gt; name [1] =&gt; age [2] =&gt; height ) ) [1] =&gt; Array ( [0] =&gt; 11 [1] =&gt; asd ) [2] =&gt; Array ( [0] =&gt; 11 [1] =&gt; table ) [3] =&gt; Array ( [0] =&gt; 15 [1] =&gt; a ) [4] =&gt; Array ( [0] =&gt; 15 [1] =&gt; a ) ) </code></pre> <p>The problem I have is that some array members I want to merge together (for example multiple -&gt;Selects()/-&gt;Where() clauses) and some array members I want to delete entirely if there are multiple instances because it isn't possible for there to be more than one (for example -&gt;Limit(), -&gt;Order()), however I'm not entirely sure what the easiest way to do this is.</p> <p>I was thinking something along the lines of a function I could call for each subkey;</p> <pre><code>DeleteDuplicates(sql_order); Merge(sql_select); </code></pre> <p>Not sure how to write these without a massive performance hit per query.</p> </div>

将数组与DataProvider数据项合并

<div class="post-text" itemprop="text"> <p>I have 2 tables in my Yii application; <strong>Category</strong> and <strong>Item</strong>.</p> <pre><code>Category - id - name Item - id - category_id - name </code></pre> <p>What I would like to do is get a list of items in <strong>Category</strong> table and subsequently count the number of items of each category in the <strong>Item</strong> table.</p> <p>I'm using CActiveDataProvider to retrieve a list of items in the the Category table and then subsequently use a for-loop to count the number of items in each category. However, I can't seem to figure out how to merge the array with my DataProvider data items.</p> <p>Here is my code so far.</p> <pre><code>public function actionIndex() { $dataProvider = new CActiveDataProvider('Category', array( 'criteria' =&gt; array( 'select' =&gt; 'id, name, slug', 'order' =&gt; 'name ASC', ), )); $dataProvider-&gt;setPagination(false); $count = array(); foreach($dataProvider-&gt;getData() as $categoryData) { $count[] = Item::model()-&gt;count("category_id = :categoryID", array("categoryID" =&gt; $categoryData-&gt;id)); } $this-&gt;render('index', array( 'dataProvider' =&gt; $dataProvider, 'count' =&gt; $count, )); } </code></pre> <p>How do I merge the $count array with my existing dataProvider data items so that I may use it with CListView? Is there a much more better solution than this?</p> </div>

弄清楚如何合并滤波器循环的数组

<div class="post-text" itemprop="text"> <p>I am creating a Wordpress website that shows events through the Eventbrite API. Using the API from <a href="https://github.com/Automattic/eventbrite-api" rel="nofollow noreferrer">https://github.com/Automattic/eventbrite-api</a> </p> <p>I was able to get the data. create a template with the events data and create a slider too. What I am trying to do is filter these events by venue id and organizer id.</p> <p>What I have done so far. </p> <p>Created a loop that goes through the events and inputs the for each loop. But it comes out as each city is a separate array so a separate drop down for each city. </p> <pre class="lang-php prettyprint-override"><code>&lt;div id="venues" class="form-group my-5"&gt; &lt;form id="venue-select" class="venue-select input-group-prepend ml-auto mt-5" action="&lt;?php echo esc_url(home_url('/')); ?&gt;" method="get" &gt; &lt;?php printf(eventbrite_event_venue()); ?&gt; &lt;?php // Set up and call our Eventbrite query. $venue_filter = new Eventbrite_Query(apply_filters( 'eventbrite_query_args', array( 'display_private' =&gt; true, // boolean) 'status' =&gt; 'live', // string (only available for display_private true) 'limit' =&gt; 100, // integer ))); if ($venue_filter-&gt;have_posts()) : while ($venue_filter-&gt;have_posts()) : $venue_filter-&gt;the_post(); $result = array(eventbrite_event_venue()); echo print_r($result); $venues = array_merge($result); $venues_array = array('Choose A City'); $get_venues = $venues; foreach ( $get_venues as $venue ) { $venues_array[] .= $venue; } $venue_id = array_unique($venues_array); printf('&lt;select name="%s" class="postform form-control"&gt;', esc_attr($venue)); foreach($get_venues as $venue) { printf( '&lt;option value="%s"&gt;%s&lt;/option&gt;', esc_attr( $venue), esc_html(eventbrite_event_venue()-&gt;address-&gt;city ) ); } print('&lt;/select&gt;'); endwhile; endif; wp_reset_postdata(); wp_reset_query(); ?&gt; &lt;/select&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>The following code</p> <pre><code> $result = array(eventbrite_event_venue()); echo print_r($result); </code></pre> <p>outputs the following: </p> <pre><code>Array ( [0] =&amp;gt; stdClass Object ( [address] =&amp;gt; stdClass Object ( [address_1] =&amp;gt; 350 5th Avenue, [address_2] =&amp;gt; 5th Floor, The LAB [city] =&amp;gt; New York [region] =&amp;gt; NY [postal_code] =&amp;gt; 10118 [country] =&amp;gt; US [latitude] =&amp;gt; 40.7353956 [longitude] =&amp;gt; -73.99462499999998 [localized_address_display] =&amp;gt; 350 5th Avenue, 5th Floor, The LAB, New York, NY 10118 [localized_area_display] =&amp;gt; New York, NY [localized_multi_line_address_display] =&amp;gt; Array ( [0] =&amp;gt; 350 5th Avenue [1] =&amp;gt; 5th Floor, The LAB [2] =&amp;gt; New York, NY 10118 ) ) [resource_uri] =&amp;gt; https://www.eventbriteapi.com/v3/venues/25816848/ [id] =&amp;gt; 25816848 [age_restriction] =&amp;gt; [capacity] =&amp;gt; [name] =&amp;gt; Global Brands Group [latitude] =&amp;gt; 40.7353956 [longitude] =&amp;gt; -73.99462499999998 ) ) 1Array ( [0] =&amp;gt; stdClass Object ( [address] =&amp;gt; stdClass Object ( [address_1] =&amp;gt; 350 5th Avenue, [address_2] =&amp;gt; 5th Floor, HR Training Room [city] =&amp;gt; New York [region] =&amp;gt; NY [postal_code] =&amp;gt; 10118 [country] =&amp;gt; US [latitude] =&amp;gt; 40.7484799 [longitude] =&amp;gt; -73.98542450000002 [localized_address_display] =&amp;gt; 350 5th Avenue, 5th Floor, HR Training Room, New York, NY 10118 [localized_area_display] =&amp;gt; New York, NY [localized_multi_line_address_display] =&amp;gt; Array ( [0] =&amp;gt; 350 5th Avenue [1] =&amp;gt; 5th Floor, HR Training Room [2] =&amp;gt; New York, NY 10118 ) ) [resource_uri] =&amp;gt; https://www.eventbriteapi.com/v3/venues/25536431/ [id] =&amp;gt; 25536431 [age_restriction] =&amp;gt; [capacity] =&amp;gt; [name] =&amp;gt; Global Brands Group [latitude] =&amp;gt; 40.7484799 [longitude] =&amp;gt; -73.98542450000002 ) ) 1Array ( [0] =&amp;gt; stdClass Object ( [address] =&amp;gt; stdClass Object ( [address_1] =&amp;gt; 350 5th Avenue, [address_2] =&amp;gt; 5th Floor, HR Training Room [city] =&amp;gt; New York [region] =&amp;gt; NY [postal_code] =&amp;gt; 10118 [country] =&amp;gt; US [latitude] =&amp;gt; 40.7484799 [longitude] =&amp;gt; -73.98542450000002 [localized_address_display] =&amp;gt; 350 5th Avenue, 5th Floor, HR Training Room, New York, NY 10118 [localized_area_display] =&amp;gt; New York, NY [localized_multi_line_address_display] =&amp;gt; Array ( [0] =&amp;gt; 350 5th Avenue [1] =&amp;gt; 5th Floor, HR Training Room [2] =&amp;gt; New York, NY 10118 ) ) [resource_uri] =&amp;gt; https://www.eventbriteapi.com/v3/venues/25536431/ [id] =&amp;gt; 25536431 [age_restriction] =&amp;gt; [capacity] =&amp;gt; [name] =&amp;gt; Global Brands Group [latitude] =&amp;gt; 40.7484799 [longitude] =&amp;gt; -73.98542450000002 ) ) 1Array ( [0] =&amp;gt; stdClass Object ( [address] =&amp;gt; stdClass Object ( [address_1] =&amp;gt; 350 5th Avenue, [address_2] =&amp;gt; 5th Floor, HR Training Room [city] =&amp;gt; New York [region] =&amp;gt; NY [postal_code] =&amp;gt; 10118 [country] =&amp;gt; US [latitude] =&amp;gt; 40.7484799 [longitude] =&amp;gt; -73.98542450000002 [localized_address_display] =&amp;gt; 350 5th Avenue, 5th Floor, HR Training Room, New York, NY 10118 [localized_area_display] =&amp;gt; New York, NY [localized_multi_line_address_display] =&amp;gt; Array ( [0] =&amp;gt; 350 5th Avenue [1] =&amp;gt; 5th Floor, HR Training Room [2] =&amp;gt; New York, NY 10118 ) ) [resource_uri] =&amp;gt; https://www.eventbriteapi.com/v3/venues/25536431/ [id] =&amp;gt; 25536431 [age_restriction] =&amp;gt; [capacity] =&amp;gt; [name] =&amp;gt; Global Brands Group [latitude] =&amp;gt; 40.7484799 [longitude] =&amp;gt; -73.98542450000002 ) ) 1Array ( [0] =&amp;gt; stdClass Object ( [address] =&amp;gt; stdClass Object ( [address_1] =&amp;gt; 350 5th Avenue, [address_2] =&amp;gt; 5th Floor, HR Training Room [city] =&amp;gt; New York [region] =&amp;gt; NY [postal_code] =&amp;gt; 10118 [country] =&amp;gt; US [latitude] =&amp;gt; 40.7484799 [longitude] =&amp;gt; -73.98542450000002 [localized_address_display] =&amp;gt; 350 5th Avenue, 5th Floor, HR Training Room, New York, NY 10118 [localized_area_display] =&amp;gt; New York, NY [localized_multi_line_address_display] =&amp;gt; Array ( [0] =&amp;gt; 350 5th Avenue [1] =&amp;gt; 5th Floor, HR Training Room [2] =&amp;gt; New York, NY 10118 ) ) [resource_uri] =&amp;gt; https://www.eventbriteapi.com/v3/venues/25536431/ [id] =&amp;gt; 25536431 [age_restriction] =&amp;gt; [capacity] =&amp;gt; [name] =&amp;gt; Global Brands Group [latitude] =&amp;gt; 40.7484799 [longitude] =&amp;gt; -73.98542450000002 ) ) </code></pre> <p>I am not sure how to merge the array into one and when you select the city, the variable should go into here to filter loop for the events </p> <pre><code> &lt;?php // Set up and call our Eventbrite query. $events = new Eventbrite_Query( apply_filters( 'eventbrite_query_args', array( 'display_private' =&gt; true, // boolean 'status' =&gt; 'live', // string (only available for display_private true) 'nopaging' =&gt; true, // boolean 'limit' =&gt; 100, // integer //'organizer_id' =&gt; $organizerfilter, // integer // 'p' =&gt; null, // integer // 'post__not_in' =&gt; null, // array of integers 'venue_id' =&gt; $venue, // integer // 'category_id' =&gt; null, // integer // 'subcategory_id' =&gt; null, // integer // 'format_id' =&gt; null, // integer ) ) ); if ( $events-&gt;have_posts() ) : while ( $events-&gt;have_posts() ) : $events-&gt;the_post(); ?&gt; &lt;?php get_template_part( 'template-parts/content', 'events' ); ?&gt; &lt;?php endwhile; // Previous/next post navigation. eventbrite_paging_nav(); else : // If no content, include the "No posts found" template. get_template_part( 'content', 'none' ); endif; // Return $post to its rightful owner. wp_reset_query(); ?&gt; </code></pre> </div>

提取数组索引并合并其他数组PHP中的项

<div class="post-text" itemprop="text"> <p>I have this array <strong>$all_designs_from_select_articles</strong> in PHP. Each index contains the objects Design:</p> <pre><code>array:7 [▼ 0 =&gt; array:12 [▼ 0 =&gt; Design {#297 ▶} 1 =&gt; Design {#298 ▶} 2 =&gt; Design {#299 ▶} 3 =&gt; Design {#300 ▶} 4 =&gt; Design {#301 ▶} 5 =&gt; Design {#302 ▶} 6 =&gt; Design {#303 ▶} 7 =&gt; Design {#304 ▶} 8 =&gt; Design {#305 ▶} 9 =&gt; Design {#306 ▶} 10 =&gt; Design {#307 ▶} 11 =&gt; Design {#308 ▶} ] 1 =&gt; array:15 [▼ 0 =&gt; Design {#309 ▶} 1 =&gt; Design {#310 ▶} 2 =&gt; Design {#311 ▶} 3 =&gt; Design {#312 ▶} 4 =&gt; Design {#313 ▶} 5 =&gt; Design {#314 ▶} 6 =&gt; Design {#315 ▶} 7 =&gt; Design {#316 ▶} 8 =&gt; Design {#317 ▶} 9 =&gt; Design {#318 ▶} 10 =&gt; Design {#319 ▶} 11 =&gt; Design {#320 ▶} 12 =&gt; Design {#321 ▶} 13 =&gt; Design {#322 ▶} 14 =&gt; Design {#323 ▶} ] ] </code></pre> <p>But I want an array with all Design keys combined, like this:</p> <pre><code>array:26 [▼ 0 =&gt; Design {#297 ▶} 1 =&gt; Design {#298 ▶} 2 =&gt; Design {#299 ▶} 3 =&gt; Design {#300 ▶} 4 =&gt; Design {#301 ▶} 5 =&gt; Design {#302 ▶} 6 =&gt; Design {#303 ▶} 7 =&gt; Design {#304 ▶} 8 =&gt; Design {#305 ▶} 9 =&gt; Design {#306 ▶} 10 =&gt; Design {#307 ▶} 11 =&gt; Design {#308 ▶} 12 =&gt; Design {#309 ▶} 13 =&gt; Design {#310 ▶} 14 =&gt; Design {#311 ▶} 15 =&gt; Design {#312 ▶} 16 =&gt; Design {#313 ▶} 17 =&gt; Design {#314 ▶} 18 =&gt; Design {#315 ▶} 19 =&gt; Design {#316 ▶} 20 =&gt; Design {#317 ▶} 21 =&gt; Design {#318 ▶} 22 =&gt; Design {#319 ▶} 23 =&gt; Design {#320 ▶} 24 =&gt; Design {#321 ▶} 25 =&gt; Design {#322 ▶} 26 =&gt; Design {#323 ▶} ... etc ] </code></pre> <p>And this is my query to my API and get the first array values:</p> <pre><code>foreach ($search_articles as $article) { $all_designs_from_select_articles[] = ApiDesign::getList([ 'article_id' =&gt; $article, 'visibility' =&gt; 'ALL', 'order' =&gt; '-POPULARITY,NAME', 'lang' =&gt; 'multi,es', ]); } </code></pre> <p>Is there a function in PHP to do this? I´m using PHP7 and the framework laravel 5.2</p> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

差点跪了...

最近微信又搞出了一个大利器,甚至都上了热搜,当然消息最敏捷的自媒体人,纷纷都开通了自己的视频号。01 视频号是什么呢?视频号是微信体系内的短视频,它不同...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

Vue回炉重造之router路由(更新中)

你好,我是Vam的金豆之路,可以叫我豆哥。2019年年度博客之星、技术领域博客专家。主要领域:前端开发。我的微信是 maomin9761,有什么疑问可以加我哦,自己创建了一个微信技术交流群,可以加我邀请你一起交流学习。最后自己也创建了一个微信公众号,里面的文章是我自己精挑细选的文章,主要介绍各种IT新技术。欢迎关注哦,微信搜索:臻美IT,等你来。 欢迎阅读本博文,本博文主要讲述【】,文字通...

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大胆预测下未来5年的Web开发

在2019年的ReactiveConf 上,《Elm in Action》的作者Richard Feldman对未来5年Web开发的发展做了预测,很有意思,分享给大家。如果你有机会从头...

立即提问
相关内容推荐