I’ve only had limited experience using PHP and I need to use it to create a filter in Moodle. I’ve created this bit of code which converts the word colour to color:
[php]<?php
class filter_helloworld extends moodle_text_filter {
public function filter($text, array $options = array()) {
return str_replace(‘colour’, ‘color’, $text);
}
}
?>[/php]
How would I make it so it can change multiple words, for example, I have a list of about 200 words to change from GB English to US English. I tried this:
[php]<?php
class filter_helloworld extends moodle_text_filter {
public function filter($strings = array();
$strings['colour'] = 'color';
$strings['centre'] = 'center';) {
foreach ($strings as $string1 => $string2) {
$text = str_replace($string1, $string2, $text);
}
}
?>[/php]
But the page didn’t load :-X
Any help would be really appreciated!