$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>php - exchange words in echo|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

php - exchange words in echo

matteradmin9PV0评论

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;

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far