Approved... the str_replace returns the string without replacing the occurences... strange.
What you might do now...
Create a snippet that takes a string as an argument, modifies it and returns the modified value.
Call that snippet via the @EVAL-binding and let it return the output of that snippet.
Your TV might take this as a default value:
@EVAL return $modx->runSnippet(’test_str’, array(’string’=> ’[*pagetitle*]’));
Your snippet should look like this for example:
<?php
$string = isset($string) ? $string : "";
return str_replace(" ", "_", $string);
?>
This should work, but doesn´t. The passed string might be no "real" string consisting of single characters...
Is it URL-encoded, HTML or somewhat?