-2

http://wwwを削除する方法。php配列から、

これがストアのURLを表示する私のコードで、 http://www.domain.comの代わりにdomain.comを表示したいだけです。また、 http ://domain.comとして表示される場合もあります。

コード:<p class="store-url"><a href="<?php echo $url_out; ?>" target="_blank"><?php echo $stores_url; ?>

この機能のため、このように表示されます

<div class="store"> 

<?php // grab the store meta data 
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
$stores_url = esc_url(get_metadata(APP_TAX_STORE, $term->term_id, 'clpr_store_url', true));
$dest_url = esc_url(get_metadata(APP_TAX_STORE, $term->term_id, 'clpr_store_aff_url', true));

// if there's a store aff link, then cloak it. else use store url
if ($dest_url)
$url_out = esc_url(home_url(CLPR_STORE_REDIRECT_BASE_URL . $term->slug));
else
$url_out = $stores_url; 

?>
4

1 に答える 1

0

試す:

<?php $stores_url = preg_replace('/^https?:\/\/(?:www\.)?/i', '', $stores_url); ?>
<p class="store-url"><a href="<?php echo $url_out; ?>" target="_blank">
    <?php echo $stores_url ?>
</p>

URLの先頭から、http://またはURLの先頭から削除されます。https://www

于 2012-08-02T18:34:47.513 に答える