admin管理员组文章数量:1026989
Hey guys thanks in advance to all,
So Iv made a conditional
statement for a plugin that runs on woocommerce, to target the URL
so I can inject custom css via php or whatever.
the code works fine, but I trying to make it cleaner using an array
instead of rewriting the statment every time
this is the code hope you guys could help cheers,
//add css if uri contains product base number
add_action('init', 'do_stuff');
function do_stuff()
{
$url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (false !== strpos($url, 'product_base=22')) {
echo '<style type="text/css"></style>';
}
}
this is the array I was thinking about looping over there are two options one with the full path and the other a constant path of product_base
with a dynamic number from the array
$product_base = array('product_base=21','product_base=22','product_base=23');
$product_key = array('21','22','23');
cheers again,
Hey guys thanks in advance to all,
So Iv made a conditional
statement for a plugin that runs on woocommerce, to target the URL
so I can inject custom css via php or whatever.
the code works fine, but I trying to make it cleaner using an array
instead of rewriting the statment every time
this is the code hope you guys could help cheers,
//add css if uri contains product base number
add_action('init', 'do_stuff');
function do_stuff()
{
$url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (false !== strpos($url, 'product_base=22')) {
echo '<style type="text/css"></style>';
}
}
this is the array I was thinking about looping over there are two options one with the full path and the other a constant path of product_base
with a dynamic number from the array
$product_base = array('product_base=21','product_base=22','product_base=23');
$product_key = array('21','22','23');
cheers again,
本文标签: phpLooping over an array of URL end points
版权声明:本文标题:php - Looping over an array of URL end points 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745614332a2159194.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论