Trying to finish up the next release, but seem to have come up with a
snag I can't figure out. I have a new function BOLTsaveEscapes. It
simply sets an in and out replace array then does a str_replace on the
text sent to it using those two arrays. In my debugging I print out
the text before, the arrays and the text out.
test & try
Array
(
[in] => Array
(
[0] => &
)
[out] => Array
(
[0] => &
)
)
test & try  
I honestly have nothing else going on--yet my & are getting double
escaped. Ah got it. The php docs suggest this instead of simple
str_replace:
strtr( $subject, array_combine($search, $replace) );
which works. But unfortunately array_combine is a php5 function!
I could work around it here locally, but I can foresee unexpected
results like this anywhere we use the replace table. It seems a better
approach is to change how the replace table is constructed and used.
That is rather than
$BOLTreplaceTable['SAVE']['in'] = Array('1', '2', '3');
$BOLTreplaceTable['SAVE']['out'] = Array('one', two', 'three');
We could generate it like this:
$BOLTreplaceTable['SAVE'] = Array('1'=>'one', '2'=>'two', '3'=>'three');
Then for processing we use
strtr($text, $BOLTreplaceTable['SAVE'])
rather than
str_replace($BOLTreplaceTable['SAVE']['in'],
$BOLTreplaceTable['SAVE']['out'], $text);
More effective all the way around. It certainly solves this problem...
And I think we can make the change without affecting plugins. Unless
they manually set the replace table rather than using the
BOLTreplace('in', 'out') function shortcut. Any comments?
Cheers,
Dan
P.S. Amazing sometimes how seemingly small changes uncover major areas
for improvement, hey?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"BoltWire" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/boltwire?hl=en
-~----------~----~----~----~------~----~------~--~---