Jump to content

is there any way to use explode like this?


kelphyr

Recommended Posts

Like if I have a line like this:

501,Red_Potion,Red Potion,0,50,,70,,,,,0xFFFFFFFF,7,2,,,,,,{ itemheal rand(45,65),0; },{},{}

 

list($script,$equip,$unequip) = explode("...", $line);

 

... = { get the stuff here inbetween } so instead of being one symbol the first one is { then } then { then }....

does that make sense?

i need to get the 3 inbetween {} {} {}

explode() isn't that smart unfortunately.  Actually I don't think any php functions can handle that sort of csv data easily.

 

If you know the three {} are always at the end, you can chop those ones off and deal with them specially.  That might be the best way to go about it.  You can explode() them on '{', and then find and remove the trailing '}' with str_replace().  The earlier data looks like it can be split safely on ','

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.