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
=>
'%'
,
'$'
=>
'$'
,
'#'
=>
'#'
,
'@'
=>
'@'
,
'!'
=>
'!'
,
'~'
=>
'~'
,
'`'
=>
'`'
,
'+'
=>
'+'
,
'-'
=>
'-'
,
'='
=>
'='
,
'_'
=>
'_'
,
'|'
=>
'|'
,
'\\'
=>
'\'
,
'\''
=>
'''
,
'"'
=>
'"'
,
';'
=>
';'
,
':'
=>
':'
,
'.'
=>
'.'
,
','
=>
','
,
'?'
=>
'?'
,
'/'
=>
'/'
,
' '
=>
' '
,
'('
=>
'︵'
,
')'
=>
'︶'
,
'【'
=>
'︻'
,
'】'
=>
'︼'
,
'《'
=>
'︽'
,
'》'
=>
'︾'
);
public
$height
= 10;
function
convert(
$original
,
$height
= null) {
$original
= preg_replace(
'/\s/'
,
''
,
$original
);
$strarr
=
$this
->mbStringToArray(
$original
);
$height
=
$height
?
intval
(
$height
) :
$this
->height;
$total
= sizeof(
$strarr
);
$width
=
ceil
(
$total
/
$height
);
$result
=
array
();
for
(
$i
= 0,
$tmp
=
array
();
$i
<
$total
;
$i
++) {
$c
=
$strarr
[
$i
];
$tmp
[] = isset(
$this
->CHARLIST[
$c
]) ?
$this
->CHARLIST[
$c
] :
$c
;
if
(sizeof(
$tmp
) ==
$height
) {
$result
[] =
$tmp
;
$tmp
=
array
();
}
}
if
(sizeof(
$tmp
)) {
$result
[] =
$tmp
;
}
$output
=
"<pre class="
brush:php;toolbar:false
">"
;
for
(
$j
= 0;
$j
<
$height
;
$j
++) {
for
(
$i
=
$width
- 1;
$i
>= 0;
$i
--) {
$output
.=
$this
->SEPARATOR;
$output
.= isset(
$result
[
$i
][
$j
]) ?
$result
[
$i
][
$j
] :
$this
->BLANK;
}
$output
.=
$this
->SEPARATOR;
$output
.=
"\n"
;
}
return
$output
."