registerFunction( 'onPrepareContent', 'botMosDirections' ); /** * Code Highlighting Mambot * * Usage: * {moscode}...some code...{/moscode} */ function botMosDirections( $published, &$row, &$params, $page=0 ) { // simple performance check to determine whether bot should process further if ( strpos( $row->text, 'mosdirections' ) === false ) { return true; } // define the regular expression for the bot $regex = "#{mosdirections}(.*?){/mosdirections}#s"; // check whether mambot has been unpublished if ( !$published ) { $row->text = preg_replace( $regex, '', $row->text ); return true; } // perform the replacement $row->text = preg_replace_callback( $regex, 'botMosDirections_replacer', $row->text ); return true; } /** * Replaces the matched tags an image * @param array An array of matches (see preg_match_all) * @return string */ function botMosDirections_replacer( &$matches ) { $text = $matches[1]; $mdarr = preg_split('/, |=/', $matches[1], -1); for ( $x = 0, $newarr = array() ; $x < count($mdarr) ; $x += 2 ) { $newarr[$mdarr[$x]] = $mdarr[$x + 1]; } print_r($newarr); $text = ("".$newarr['test1']."" ); return $text; } ?>