The conversation between human and AI assistant.
How do I justify content in string using PHP?
That's helpful. Is there a way to justify text on both sides?
Yes, you can use the STR_PAD_BOTH flag instead of STR_PAD_LEFT or STR_PAD_RIGHT to justify the text on both sides. Here's an example:
```php
$string = "Hello";
$padding = "-";
$justified_string = str_pad($string, 11, $padding, STR_PAD_BOTH);
echo $justified_string;
```
This code will output: "--Hello---"