I have a form which when submitted, an array will be passes. The elements inside that array will be separated using rxml. This is how I tried:
$options = $this->request->data('options');
$count = count ($options);
$rxml = "<rslist>";
for ($i = 0; $i < $count; $i++) {
$trimmedOption = trim($options[$i], " ");
$rxml = $rxml.'<rs option="'.$trimmedOption.'" />';
}
$rxml = $rxml . "</rslist>";
When an element is converted in to a string, first it gets trimmed, because there is some white space in right side of the string. Like this opton-1
.
In order to remove that space, I used that trim option. But, this is not working.
I tried:
str_replace(' ', '', $options[$i]);
rtrim($options[$i]);
too. But, nothing worked. That string got saved with that extra space only. So, what should I do? What should I change?