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
Need help with preg_match with array
Old 11-23-2010, 01:39 AM Need help with preg_match with array
ZoC
Skilled Talker

Posts: 68
Trades: 0
Hello there, this is my script hope someone can fix this for me ...

PHP Code:
<?php

$allow 
= array(
    
'http://www.google',
    
'http://search.yahoo.com'
);

 if (
in_array($_SERVER['REMOTE_ADDR'], "~$allowed_ips~i")) {
  echo 
"a";
 } else {
  echo 
"b";
 }

?>
Right now im using this command

PHP Code:
if (strpos($_SERVER["HTTP_REFERER"], "http://www.google")) { "a"; } 
But hope someone can help me to make this, to read from array so can be more easy for me to add the websites what i need

Thank you !

Last edited by ZoC; 11-23-2010 at 02:03 AM..
ZoC is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-23-2010, 11:02 AM Re: Need help with preg_match with array
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
You can't use preg_match with array but you can use implode before matching instead.

PHP Code:
<?php

$allow 
= array(
    
'http://www.google',
    
'http://search.yahoo.com'
);

$combined_array implode(',',$allow);

if (
strpos($_SERVER["HTTP_REFERER"], $combined_array)) { "a"; } 

?>
__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 11-23-2010, 12:05 PM Re: Need help with preg_match with array
ZoC
Skilled Talker

Posts: 68
Trades: 0
i try like this

PHP Code:
<?php

$allow 
= array(
    
'a',
    
'b'
);

$combined_array implode(',',$allow);

if (
strpos('asd'$combined_array)) { "a"; } 

?>
normaly was need to show me ( a ) but is not show, can you please tell me how i can fix this, thank you
ZoC is offline
Reply With Quote
View Public Profile
 
Old 11-23-2010, 12:11 PM Re: Need help with preg_match with array
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
use echo "a" instead of just "a"
__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 11-24-2010, 01:07 AM Re: Need help with preg_match with array
ZoC
Skilled Talker

Posts: 68
Trades: 0
i try but didnt work for me
ZoC is offline
Reply With Quote
View Public Profile
 
Old 11-25-2010, 06:35 AM Re: Need help with preg_match with array
Extreme Talker

Posts: 156
Trades: 0
What does the script look like now?
dagaul101 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need help with preg_match with array
 

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.33407 seconds with 12 queries