Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
help!! some simple questions?
Old 01-06-2010, 01:00 PM help!! some simple questions?
Average Talker

Posts: 22
Name: Rikesh Bajracharya
Trades: 0
hi i am totaly a beginner and seeking some simple help. i have a lot of question but right now i am asking u one.

Q.
example i have
$a = http://www.sitename.com/
$b = http://www.sitename.com/page1/index.php
$c = http://www.sitename.com/page2/home.php

how can i compare and search for "http://www.sitename.com" in $b and $c and count how many times it repeats.

thanks in advance.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by easyflashgames; 01-07-2010 at 05:33 AM..
easyflashgames is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-06-2010, 03:44 PM Re: help!! some simple questions?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
http://us2.php.net/manual/en/function.substr-count.php

PHP Code:
$count substr_count($b$a); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 01-07-2010, 05:32 AM Re: help!! some simple questions?
Average Talker

Posts: 22
Name: Rikesh Bajracharya
Trades: 0
hi thanks i will try to use it.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
easyflashgames is offline
Reply With Quote
View Public Profile
 
Old 01-10-2010, 04:28 PM Re: help!! some simple questions?
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
or, you can use preg_match

instead of
$a = http://www.sitename.com/
$b = http://www.sitename.com/page1/index.php
$c = http://www.sitename.com/page2/home.php

write:

$compare_regex = '/www\.sitename\.com\/page1/';
$ar = array(
'http://www.sitename.com/',
'http://www.sitename.com/page1/index.php',
'http://www.sitename.com/page2/home.php'
); $times = 0;
foreach($ar as $vals) {
if(preg_match($compare_regex, $vals)) $times++;
} echo $times;
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Reply     « Reply to help!! some simple questions?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21912 seconds with 12 queries