Jump to content

[SOLVED] Converting string to orderd list


pacchiee

Recommended Posts

Hello,

 

I wanted to convert a string to an ordered list. Something like below:

 

EX-1

$string = "a,b,c,d,e,f";

The above string should be listed as

1. a

2. b

3. c

4. d

5. e

6. f

 

EX-2

$string = "a,b";

The above string should be listed as

1. a

2. b

 

EX-3

$string = "a";

The output should be

1. a

 

I thought of using list(), but the number of variables may differ in the string and don't know how to handle it.

 

Please help. Thanks in Advance.

 

Link to comment
https://forums.phpfreaks.com/topic/164688-solved-converting-string-to-orderd-list/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.