关联数组中的值数组在推入父数组时会创建键

时间:2019-06-28 08:39:58

标签: php arrays wordpress associative-array

我想向此WP_Query <div class="edit-practitioner" style="display: none;"> <form style="box-shadow: none;" action="/practitioner/update/{{$practitioner->practitioner_id}}" method="post" class="j-pro" id="update-practitioner-form"> {{ csrf_field() }} <div class="j-content"> <div id="j-row-id" class="j-row"> <div class="row"> <div class="col-sm-12 col-lg-12 col-xl-5"> <div class=" j-unit"> <div class="j-divider-text j-gap-top-20 j-gap-bottom-45"> <span>Practitioner Information</span> </div> <label class="j-label">{{trans('personalData.effectiveDate')}}</label> <div class="j-input"> <input type="date" value="{{$practitioner->effective_date}}" name="effective_date" id="effective_date"> </div> <label class="j-label">{{trans('personalData.expiryDate')}}</label> <div class="j-input"> <input type="date" value="{{$practitioner->expiry_date}}" name="expiry_date" id="expiry_date"> </div> <label class="j-label">{{trans('personalData.phoneNumber')}}</label> <div class="j-input"> </label> <input type="tel" value="{{$practitioner->phone}}" name="phone" id="phone"> </div> <label class="j-label">{{trans('personalData.mobileNumber')}}</label> <div class="j-input"> <input type="tel" value="{{$practitioner->mobile}}" name="mobile" id="mobile"> </div> <label class="j-label">{{trans('personalData.email')}}</label> <div class="j-input"> <input type="email" value="{{$practitioner->email}}" name="email" id="email"> </div> </div> </div> <div class="col-xl-1 j-unit"></div> <div class="col-sm-12 col-lg-12 col-xl-6"> <div class="j-divider-text j-gap-top-20 j-gap-bottom-45"> <span>{{trans('settings.specialty')}}</span> </div> <select name="practitioner_specialty_id_update" id="practitioner_specialty_id_update" class="form-control-practitioner required"> @foreach($specialties as $specialty) <option value="{{$specialty->specialty_id}}">{{$specialty->name}}</option> @endforeach </select> <label class="j-label">{{trans('personalData.effectiveDate')}}</label> <div class="j-input"> @isset($practitioner_specialty->practitioner_specialty_id) <input type="date" value="{{$practitioner_specialty->effective_date}}" name="effective_date" id="effective_date"> @endisset @empty($practitioner_specialty->practitioner_specialty_id) <input type="date" name="effective_date" id="effective_date"> @endempty </div> <label class="j-label">{{trans('personalData.expiryDate')}}</label> <div class="j-input"> @isset($practitioner_specialty->practitioner_specialty_id) <input type="date" value="{{$practitioner_specialty->expiry_date}}" name="expiry_date" id="expiry_date"> @endisset @empty($practitioner_specialty->practitioner_specialty_id) <input type="date" name="expiry_date" id="expiry_date"> @endempty </div> </div> </div> </div> <div class="j-divider j-gap-bottom-45 j-gap-top-10"></div> <button type="submit" class="btn btn-editpanel btn-success btn-round">Save changes </button> <!-- end /.footer --> <button id="update-cancel-button-practitioner" href="javascript:window.location.href=window.location.href" type="button" class="btn btn-editpanel btn-danger btn-round">Cancel </button> </div> </form> </div> 数组添加键。它们具有嵌套数组,对于后格式,$args必须具有一个没有键才能工作的值数组。但是,添加密钥时,它将自动创建密钥terms

PHP:

'0' => 'value'

Var dump:

$args = array(
 'hierarchical' => true, 
 'posts_per_page' => $posts_per_page,
);

$post_formats_query = array(             
    'taxonomy' => 'post_format',
    'field' => 'slug',
    'terms' => array('post-format-'. $format_value);
);

$args['tax_query']=$post_formats_query; //this seems to create unwanted key

0 个答案:

没有答案