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
split u php-u

 
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
Filip



Joined: 12 Jan 2008
Posts: 19

PostPosted: 15.02.2008 16:08    Post subject: split u php-u Add user to your forum ignore list Reply with quote

Imam ovaj code
Code:

$data="123.123.123.*";
$polje = spliti('.',$data,-1);
print_r($polje);

a kao rjesenje dobivam
Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => [12] => [13] => )

pa mi nije jasno, zašto ne može razdijeliti po '.'?
ima netko ideju?[/code]
Back to top
View user's profile Send private message
liban0n



Joined: 10 Feb 2004
Posts: 128
Location: Dubrovnik, Zagreb

PostPosted: 15.02.2008 16:12    Post subject: Add user to your forum ignore list Reply with quote

$polje = spliti('\.',$data,-1);

Regularni izrazi su u pitanju, tocka predstavlja jedan-bilo koji karakter. Da bi splitao ili trazio nesto sto u sebi ima "." moras to "\." tako trazis doslovno ono sto hoces.

jos jedna stvar sto ja volim

function print_pre($pre)
{
echo "<pre>";
print_r($pre);
echo "</pre>";
}

i onda umjesto print_r koristim print_pre formatiran ispis i jasnije se vidi rezultat. Jednom kad se naviknes nikad vise print_r

_________________
mount -t swap /dev/brain /mnt/head
look'n for a job
Back to top
View user's profile Send private message Visit poster's website
Filip



Joined: 12 Jan 2008
Posts: 19

PostPosted: 15.02.2008 16:21    Post subject: Add user to your forum ignore list Reply with quote

Hvala na tako brzom odgovoru liban0n

sad radi, tko bi rekao da '.' predstavlja specijalni znak Smile
Back to top
View user's profile Send private message
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 15.02.2008 16:47    Post subject: Add user to your forum ignore list Reply with quote

Explode ti ne pase iz nekog specificnog razloga (gledam ovaj -1 param, al ne kuzim vezu s
primjerom) ili? Naime, s explode() ne moras uopce brinuti o regular expressionima i sl...

Primjer naime radi case-insensitive search za tocku, koja, kolko ja znam, ima samo jedan case Smile

http://hr.php.net/explode

_________________
[+]I[+]am[+]my[+]own[+]religion[+]
Back to top
View user's profile Send private message Visit poster's website Twitter profile
liban0n



Joined: 10 Feb 2004
Posts: 128
Location: Dubrovnik, Zagreb

PostPosted: 15.02.2008 16:51    Post subject: Add user to your forum ignore list Reply with quote

Da i ja tek sad sam primjetio taj "-1" to je u principu limit koliko redova ce vratiti split.

_________________
mount -t swap /dev/brain /mnt/head
look'n for a job
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