Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Need Simple replace code for Unicode
Old 04-01-2009, 05:50 AM Need Simple replace code for Unicode
ISSC's Avatar
Skilled Talker

Posts: 65
Name: A. Mansouri
Location: Jeddah, K.S.A
Trades: 0
Dear Php Proggramers,

I need simple Unicode converter.

I try this one:
PHP Code:
$Text "50";
$beforeNu = array("0","1","2","3","4","5","6","7","8","9");
  
$afterNu  = array("0030","0031","0032","0033","0034","0035","0036","0037","0038","0039");
  
$Msg   str_replace($beforeNu$afterNu$Text);
 
echo 
$Msg
But The output for this code comes: 00350000330
It should come: 00350030

So, I think there is some reconverting in the code,
The Soloution Should be to convert each char. in once only (like foreach).

The other soloution I found it like:
PHP Code:
$fruit = array('a' => 'apple''b' => 'banana''c' => 'cranberry');
 
reset($fruit);
while (list(
$key$val) = each($fruit)) {
    echo 
"$key => $val\n";

But This Code is coming with [WHILE] witch is not giving me all converted in one Variable.

Please give help to find a soluotion.

Best Regards,
A. Mansouri
ISSC is offline
Reply With Quote
View Public Profile Visit ISSC's homepage!
 
 
Register now for full access!
Old 04-01-2009, 07:21 AM Re: Need Simple replace code for Unicode
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
How about this?
PHP Code:
$convert = array(
   
'0' => '0030',
   
'1' => '0031',
   
'2' => '0032',
   
'3' => '0033',
   
'4' => '0034',
   
'5' => '0035',
   
'6' => '0036',
   
'7' => '0037',
   
'8' => '0038',
   
'9' => '0039'
);

$text '50';
$len strlen($text);
$Msg '';
for (
$i 0$i $len$i++) {
   if (
is_numeric($text[$i])) {
      
$Msg .= $convert[$text[$i]];
   }

__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 04-01-2009, 01:29 PM Re: Need Simple replace code for Unicode
ISSC's Avatar
Skilled Talker

Posts: 65
Name: A. Mansouri
Location: Jeddah, K.S.A
Trades: 0
I Think It's Work fine.

Thank you [ lizciz ] Very Much.

Best Regards,
A. Mansouri
ISSC is offline
Reply With Quote
View Public Profile Visit ISSC's homepage!
 
Reply     « Reply to Need Simple replace code for Unicode
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26865 seconds with 12 queries