Advance uses

Nested Twists

TextTwister allows for ‘nesting’ one layer of twistable text within another for example.

includes this twistable section {panda|grizzly|scary} within the twistable list of animals.

This changes our twisted text example to give 15 possible sentences as opposed to 9 possible sentences as above.

<?php texttwister(“Spot is a {red|blue|yellow} stuffed {dog|cat|{panda| grizzly|scary} bear}.”); ?>

Spot is a red stuffed cat.
Spot is a blue stuffed dog.
Spot is a blue stuffed cat.
Spot is a yellow stuffed dog.
Spot is a yellow stuffed cat.
Spot is a yellow stuffed panda bear.
Spot is a yellow stuffed grizzly bear.
Spot is a yellow stuffed scary bear.
Spot is a red stuffed panda bear.
Spot is a red stuffed grizzly bear.
Spot is a red stuffed scary bear.
Spot is a blue stuffed panda bear.
Spot is a blue stuffed grizzly bear.
Spot is a blue stuffed scary bear.

Using TextTwister in your code

Another feature of TextTwister is the get_texttwister function that you can twist your text and then return the output for use in your code.

<?php $text = get_texttwister(“Spot is a {red|blue|yellow} stuffed {dog|cat| bear}.”); ?>

Using quotes in your strings

To use double quotes in texttwister they must be escaped first by preceding then with a backslash like this.

<?php texttwister("This is a sentence with \"quotes\" in and {has two possible endings|shows that quotes need to be escaped using backslashes}."); ?>
Was this article helpful to you? Yes 2 No

How can we help?