我使用var_dump拥有如下数组
array(26) {
["SUPPLIER_NAME"]=>
string(14) ""Company Ltd""
["INACTIVATE"]=>
string(13) ""Keep Active""
["SUPPLIER_INACTIVE_DATE"]=>
string(0) ""
["SITE_INACTIVE_DATE"]=>
string(0) ""
["ADDRESS2"]=>
string(0) ""
["ADDRESS3"]=>
string(0) ""
}
但是,当我尝试执行以下操作时,它为空白,没有值返回
echo $array["SUPPLIER_NAME"]
当我执行其他任何键时,它都起作用,只是在 SUPPLIER_NAME
上不起作用有什么想法吗?
已编辑
我们使用如下数组(我只是引用该数组中的第一个键):
echo '<pre>';
var_dump($result[0]);
echo '</pre>';
这将产生:
array(26) {
["SUPPLIER_NAME"]=>
string(14) ""Company Ltd""
["SUPPLIER_TYPE"]=>
string(13) ""Keep Active""
...
...
["ADDRESS2"]=>
string(0) ""
["ADDRESS3"]=>
string(0) ""
}
然后我尝试执行以下操作,不会吐出任何东西:
echo '<pre>';
print_r($result[0]["SUPPLIER_NAME"]);
echo '</pre>';
但是,这会产生正确的数据(其他所有键也都可以工作):
echo '<pre>';
print_r($result[0]["SUPPLIER_TYPE"]);
echo '</pre>';
我做了以下事情:
echo '<pre>';
var_dump(array_keys($result[0]));
echo '</pre>';
我知道了
array(26) {
[0]=>
string(16) "SUPPLIER_NAME"
答案 0 :(得分:1)
您的数组中有一个隐藏的字符:
<div class="dropdown dropdown-inline" data-toggle="kt-tooltip" title="" data-placement="right" data-original-title="Quick filters">
<a href="#" class="btn btn-icon" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="flaticon-interface-7"></i>
</a>
<div class="dropdown-menu dropdown-menu-fit dropdown-menu-md dropdown-menu-right" x-placement="bottom-end" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(-224.75px, 35.25px, 0px);">
<!--begin::Nav-->
<ul class="kt-nav">
<li class="kt-nav__head">
Filter Options:
</li>
<li class="kt-nav__separator"></li>
<li class="kt-nav__item">
<div class="form-group m-3">
<label>Status:</label>
<select class="form-control" name="status" id="status-dropdown">
<option value="">Select</option>
<option value="only_active">Active</option>
<option value="only_inactive">Inactive</option>
<option value="only_retired">Retired</option>
</select>
</div>
</li>
<li class="kt-nav__item">
<div class="form-group m-3">
<label>Introduced Between:</label>
<div class="input-group flatpickr kt-input-icon kt-input-icon--right">
<input class="form-control flatpickr-input" placeholder="Start Date" id="introduced_at_start" data-datetimepicker>
<span class="kt-input-icon__icon kt-input-icon__icon--right">
<span><i class="flaticon-calendar-with-a-clock-time-tools"></i></span>
</span>
</div>
<small class="text-center font-weight-bold text-muted d-block">to</small>
<div class="input-group flatpickr kt-input-icon kt-input-icon--right">
<input class="form-control flatpickr-input" placeholder="End Date" id="introduced_at_end" data-datetimepicker>
<span class="kt-input-icon__icon kt-input-icon__icon--right">
<span><i class="flaticon-calendar-with-a-clock-time-tools"></i></span>
</span>
</div>
</div>
</li>
<li class="kt-nav__separator"></li>
<li class="kt-nav__foot">
<a class="btn btn-label-brand btn-bold btn-sm" href="#" id="applyFilters">Apply Filters</a>
<a class="btn btn-clean btn-bold btn-sm" href="#" id="clearFilters">Clear Filters</a>
</li>
</ul>
<!--end::Nav-->
</div>
</div>