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
  • 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
Add a comment  | 

1 Answer 1

Reset to default 1

The 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
Add a comment  | 

1 Answer 1

Reset to default 1

The 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