php - preg_replace not working in snippet -


i tying use following modx evo snippet (naming "removespace") output tv removing space in string:

<?php $string1 = "[*longtitle*]";  $string = preg_replace('/\s+/', '', $string1); return $string; ?> 

but calling snippet [[removespace]] in template not produce string space removed. produces string is.

but inserting text "hello world" in $string1 variable produces result without space.

any solution?

you can not use modx tags inside snippets, need use $modx->documentobject['variable-name']

so code this:

<?php $string1 = $modx->documentobject['longtitle'];  $string = preg_replace('/\s+/', '', $string1); return $string; ?> 

Comments

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -