PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 3rd, 2002, 03:47 AM
ResNet9 ResNet9 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 101 ResNet9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to ResNet9
string to char?

Is there a function that can take a string and make it into a array of characters like in Java?

Reply With Quote
  #2  
Old September 3rd, 2002, 05:59 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to EvilivE
RE: string to char?

There is no function for that. A string is an array of chars.
php Code:
Original - php Code
  1. <?
  2. $foo = "This is a string";
  3.  
  4. // This will output the entire string
  5. for($i=0;$i<strlen($foo);$i++){
  6.   echo $foo[$i];
  7. }
  8.  
  9. // This will also output the entire string
  10. echo $foo;
  11. ?>

Reply With Quote
  #3  
Old September 3rd, 2002, 07:43 AM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: string to char?

You shouldn't need to. If you have your string in a variable called $str, you can call individual characters using: $str[x] replacing 'x' with a number, e.g.: $str[5]

If you do need to put the characters into a specific array, try this:

php Code:
Original - php Code
  1.  
  2. <?
  3.  $str = "Codewalkers is great";
  4.  $str_array = array ();
  5.  
  6.  for($i=0; $i<strlen($str); $i++)
  7.  {
  8.   $str_array[] = $str[$i];
  9.  }
  10.  
  11.  print_r($str_array);
  12.  
  13. ?>

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > string to char?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway