我还在学习php,这次不能实现这段代码。我需要一些帮助。
我有这个问题:
$query = tep_db_query("select c.categories_id, c.categories_image, cd.categories_name,
c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . "
cd where c.parent_id = '0' and c.categories_id IN ('25', '29', '41') and
c.categories_id = cd.categories_id order by cd.categories_name ASC");
结果,我得到了这个数组:
Array ( [41] => Acura Parts and Accessories [29] => Honda Exterior Accessories
[25] => Toyota Engine Parts)
我创建了这个短类别名称数组:
$shortNames = array('25' => 'Toyota', '29' => 'Honda', '41' => 'Acura');
我需要在以下代码中回显长类别名称,匹配id并回显短名称。
while ($categories = tep_db_fetch_array($categories_query)) {
<a href="<?php echo tep_href_link(FILENAME_DEFAULT, 'cPath='.$categories['categories_id']); ?>">
<?php echo $categories['categories_name']; ?>
</a>
}
我一直在研究一些foreach样本,但无法真正深入研究。
谢谢!!!
答案 0 :(得分:2)
好吧,如果我明白你要做什么,那就是这样的:
app.directive('numericOnly', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, modelCtrl) {
modelCtrl.$parsers.push(function (inputValue) {
var transformedInput = inputValue ? inputValue.replace(/[^\d.-]/g,'') : null;
if (transformedInput!=inputValue) {
modelCtrl.$setViewValue(transformedInput);
modelCtrl.$render();
}
//clear beginning 0
if(transformedInput == 0){
modelCtrl.$setViewValue(null);
modelCtrl.$render();
}
return transformedInput;
});
}
};
})