Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Converting Characters In A Variable To Individual Values In An Array, turning variables into arrays
electriic ink
post Apr 24 2006, 07:00 AM
Post #1


Incest is a game the whole family can play.
Group Icon

Group: [MODERATOR]
Posts: 1,217
Joined: 11-February 05
From: Heaven
Member No.: 3,709



Say I have a variable such as $nav_item and it had to contents Home. IE:

CODE
$nav_item = 'Home';


How would I make so that $nav_item was an array and had the following contents?

CODE
$nav_item = array ('h', 'o', 'm', 'e');


With the case changing (ie H would become h and U would become u)

EDIT: Okay found out that I could change the case with array_change_key_case ($nav_item, CASE_LOWER);
Go to the top of the page
 
+Quote Post
WindAndWater
post Apr 24 2006, 12:39 PM
Post #2


Advanced Member
*******

Group: Members
Posts: 106
Joined: 1-April 06
Member No.: 21,148



Taken from http://us2.php.net/manual/en/function.preg-split.php
CODE
$str = 'string';
$chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);


You can also just access individual characters in as string by treating it like an array, so "$str[2]" would return "r".
Go to the top of the page
 
+Quote Post
electriic ink
post Apr 24 2006, 06:13 PM
Post #3


Incest is a game the whole family can play.
Group Icon

Group: [MODERATOR]
Posts: 1,217
Joined: 11-February 05
From: Heaven
Member No.: 3,709



Thank you WindAndWater smile.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Max Characters Is X?(3)
  2. Transfer Variables To Another Php Script(8)
  3. <textarea> Tag Is Not Accepting Php Variable(2)
  4. Session Variables(4)
  5. Spliting An Array(4)
  6. Php Form Help!(3)
  7. Basic Tutorial On Arrays(3)
  8. Include And Values(3)
  9. Storing Session Variables Generated Dynamically(3)
  10. Php Escaped Control Characters And Windows(3)
  11. More Dynamic ?id=browsing With Php (associative Array)(1)
  12. How Do I Pass Php Variables From A Url To A Form?(5)
  13. Problem With Global Arrays(2)
  14. [php](simple) Using Functions To Combine Values In A Form(2)
  15. Passing Values By Get(16)
  1. Reading Files From Directory To Array, And Using $_get To Get Them(2)
  2. Sending $_get[] Variables To An Application(3)
  3. Validation Script - Detecting Illegal Characters(0)
  4. Using Multiple Selection Array In Table To Order Data(1)
  5. Php An Js Window.open Pages Trouble.(3)
  6. Getting An Array Value Of A Dynamic Variable(9)
  7. Arrays Outside A Function(3)
  8. Converting Textarea Return Characters To <br />(9)
  9. Php Sessions And Post Variables Issues(1)
  10. Counting Variables?(4)
  11. Script Help Required: Undefined Variable(3)
  12. Remove A Value From A Php Array Based On Its Value(5)
  13. Unexpected T_variable...(3)


 



- Lo-Fi Version Time is now: 8th September 2008 - 09:26 AM