1
Anonymous
Stupid question... please answer :)
  • 2004/1/31 3:50

  • Anonymous

  • Posts: 0

  • Since:


Hey i've got a stupid PHP question.
I'm trying to figure out how I can tokenize a string to array that's set up like this... the string will look like...

[info1][info2][info3][info4]...

I want to extract each data item between the [,] brackets into seperate members of the array. so the array would like like..
array[0] = info1
array[1] = info2
array[2] = info3
array[3] = info4
...

I know you can do this with ereg() but I am unfamiliar with it and having stared at a book for past 15 minutes I still can't seem to understand how to get it to do what I want. Thanks to whoever can help.

2
Dave_L
Re: Stupid question... please answer :)
  • 2004/1/31 4:11

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


$text '[info1][info2][info3][info4]';
preg_match_all('/[(.*?)]/'$text$matches);
$foo $matches[1];


$foo (or $matches[1]) is the desired array.

Login

Who's Online

321 user(s) are online (285 user(s) are browsing Support Forums)


Members: 0


Guests: 321


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits