Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Regex? Lots of Luck? im not sure which i need....

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Regex? Lots of Luck? im not sure which i need....

Postby yK » Tue Nov 25, 2003 6:42 am

Hello everyone,

My problem is getting info from a string and putting the data into a multidimensional array, the string will have contain just two different combinations of characters.

The first is ^1 where 1 can be any number.

The second will be ^1{ } where 1 can be any number again and within the curly brackets can be any combination of further sequences.

This is where it gets complicated; each sequence ^1 corresponds to the value of $name1 & $info1; I need an array which contains the values for each of the sequences found.

As an example i might have the following string:

$string = "^1^2{^3}";

$name1 = "enone";
$info1 = "exone";

$name2 = "entwo";
$info2 = " "; // does not have any info because it is a container...

$name3 = "enthree";
$info3 = "exthree";

For this sequence i would need to return the value from an array like this:

$array[1][name] would output "enone"

Obviously the actual strings will be much longer and much more complex but that’s just an example...

I can't think how to do it, the only way I thought might work would be regex, but I couldn’t find a way to apply it to my problem.

Appreciate any help :)
yk
User avatar
yK
New php-forum User
New php-forum User
 
Posts: 28
Joined: Tue Aug 19, 2003 1:27 pm

Postby yK » Tue Nov 25, 2003 5:30 pm

thinking about it, i'm overcomplicating things for myself.... i might just start the whole thing again and re-write the other guys code in XML....

anyone know a good XML/PHP tutorial?! (the manual isnt very helpful on the subject and i heard that XML has been re-written for PHP5 anyway.....)
User avatar
yK
New php-forum User
New php-forum User
 
Posts: 28
Joined: Tue Aug 19, 2003 1:27 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.