admin管理员组文章数量:1130349
with this code
$wptitle = str_replace(array('Versandkostenfrei'), 'Kostenloser Versand', $wptitle);
I exchange words in one of my loops.
Now I am trying to change a word that is called with echo $term->name; how do I implement that? I tried
<?php
$wptitle = str_replace(array(' .echo ($term->name;)'), '', $wptitle);
?>
but its obviously not working :-(
with this code
$wptitle = str_replace(array('Versandkostenfrei'), 'Kostenloser Versand', $wptitle);
I exchange words in one of my loops.
Now I am trying to change a word that is called with echo $term->name; how do I implement that? I tried
<?php
$wptitle = str_replace(array(' .echo ($term->name;)'), '', $wptitle);
?>
but its obviously not working :-(
Share Improve this question edited Nov 22, 2018 at 22:56 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 21, 2018 at 14:12 joloshopjoloshop 211 silver badge8 bronze badges 5 |1 Answer
Reset to default 1The PHP echo language construct that outputs the parameters passed. You don't want to do that in the middle of str_replace. To replace $term->name with an empty string, use:
$wptitle = str_replace( $term->name, '', $wptitle );
Then when you want to print it, use:
echo $wptitle;
with this code
$wptitle = str_replace(array('Versandkostenfrei'), 'Kostenloser Versand', $wptitle);
I exchange words in one of my loops.
Now I am trying to change a word that is called with echo $term->name; how do I implement that? I tried
<?php
$wptitle = str_replace(array(' .echo ($term->name;)'), '', $wptitle);
?>
but its obviously not working :-(
with this code
$wptitle = str_replace(array('Versandkostenfrei'), 'Kostenloser Versand', $wptitle);
I exchange words in one of my loops.
Now I am trying to change a word that is called with echo $term->name; how do I implement that? I tried
<?php
$wptitle = str_replace(array(' .echo ($term->name;)'), '', $wptitle);
?>
but its obviously not working :-(
Share Improve this question edited Nov 22, 2018 at 22:56 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 21, 2018 at 14:12 joloshopjoloshop 211 silver badge8 bronze badges 5-
What is
.echo ($term->name;)in an array? – Gufran Hasan Commented Nov 21, 2018 at 14:18 -
Can you show the part where
echo $term->name;occurs? (couple of lines before and after so we have context) – kero Commented Nov 21, 2018 at 14:19 - I am using ´<?php echo $term->name; ?>´ to show a Word in a custom taxonomy/theme – joloshop Commented Nov 21, 2018 at 14:21
-
You'll probably want something like
$wptitle = str_replace($term->name, 'neuer Text', $wptitle);(also, this isn't a wordpress question. this is a PHP question) – ChrisG Commented Nov 21, 2018 at 14:29 - thanks working, sorry using it in my Wordpress theme, but you are right its php sorry und thanks! – joloshop Commented Nov 21, 2018 at 14:34
1 Answer
Reset to default 1The PHP echo language construct that outputs the parameters passed. You don't want to do that in the middle of str_replace. To replace $term->name with an empty string, use:
$wptitle = str_replace( $term->name, '', $wptitle );
Then when you want to print it, use:
echo $wptitle;
本文标签: phpexchange words in echo
版权声明:本文标题:php - exchange words in echo 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749158683a2325030.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


.echo ($term->name;)in an array? – Gufran Hasan Commented Nov 21, 2018 at 14:18echo $term->name;occurs? (couple of lines before and after so we have context) – kero Commented Nov 21, 2018 at 14:19$wptitle = str_replace($term->name, 'neuer Text', $wptitle);(also, this isn't a wordpress question. this is a PHP question) – ChrisG Commented Nov 21, 2018 at 14:29