Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
PHP problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
darko



Joined: 03 Oct 2006
Posts: 20

PostPosted: 12.01.2010 22:15    Post subject: PHP problem Add user to your forum ignore list Reply with quote

Bok ekipo,
Zaglavio sam opako, trebam savjet.

Problem je sljedeći: moram u php-u parsat jedan file sa malo specifičnom strukturom nalik na xml.
Podaci su u file-u složeni u svojevrsne "blokove" limitirane sa nazovimo "tagovima" <block> i </block>. Evo konkretan primjer:

<block>
<situation>action</situation>
<situation mod="search">night</situation>
<situation mod="search">day</situation>
<situation mod="area">mountain</situation>
<situation mod="area">forrest</situation>
<situation mod="area">city</situation>
</block>

E sad, podatke iz svakog "bloka" moram spremiti u bazu u parovima. Vrijednost unutar <situation> tag-a mora imati pridruženu vrijednost iz <situation mod="xyz"> tag-a.
Krajnji rezultat iz gornjeg primjera bio bi:

action - night
action - day
action - mountain
action - forrest
action - city


Znači moram "pročešljat" cijeli file, prepoznati blokove, izvući prvu vrijednost i sa njom napraviti par iz ostalih vrijednosti.

Pokušavao sam preko raznih string funkcija, uspijem izvući vrijednosti zasebno ali nikako ne mogu složiti parove na gore navedeni način.

Ima li možda tko kakav pametan prijedlog kako ovo riješiti?

Puno hvala unaprijed!

D.
Back to top
View user's profile Send private message
strija



Joined: 14 Sep 2003
Posts: 473
Location: Čakovec

PostPosted: 13.01.2010 01:19    Post subject: Add user to your forum ignore list Reply with quote

Pa nije samo nalik na XML vec je to XML. Pogledaj si malo:
http://www.php.net/manual/en/simplexml.examples-basic.php

_________________
We can exist in ambiguity, but it means the deepest loneliness. | creolab.hr | thefarewellreason.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group