- function in_mdarray($needle,$array)
- {
- if (array_key_exists($needle,$array) or in_array($needle,$array))
- {
- return true;
- }
- else
- {
- $return = false;
- foreach (array_values($array) as $value)
- {
- if (is_array($value) and !$return)
- {
- $return = in_mdarray($needle,$value);
- }
- }
- return $return;
- }
- }
ESHAN
Please Help Any Helpless Person
02 May, 2010
Check If A Value Exists In Multidimensional Array
Here is a function which will help you to know if a value exists in Multidimensional Array.
01 May, 2010
Check If A Value Exists In Associative Array
The "in_array" function of php checks if a value exists in an array. But it don't work properly with associative array. Here is a function which will work properly with associative array.
- function in_assoc($needle,$array)
- {
- $key = array_keys($array);
- $value = array_values($array);
- if (in_array($needle,$key)){return true;}
- elseif (in_array($needle,$value)){return true;}
- else {return false;}
- }
23 March, 2010
Grab All Links Of Web Page Using Python
I always try to make useful program to learn a Programming Language. Now I am trying to learn Python. I will try to post my practice code here. Today I will show you how to grab all links of web page using Python's "BeautifulSoup" module.
- import urllib,BeautifulSoup
- def get_links(url):
- page = urllib.urlopen(url)
- soup = BeautifulSoup.BeautifulSoup(page.read())
- aTag = soup.findAll("a")
- link = []
- for a in aTag:
- if a.has_key("href"):
- link.append(a['href'])
- return link
- print get_links("http://localhost/PRACTIECE/a2/")
Enjoy!!!
23 February, 2010
Replace Links With Html
You can replace links with html tag using PHP regular expression.
Here is an example of it.
Here is an example of it.
- function replace_link_with_link($string)
- {
- $pattern = "|http://(\w+)([A-Z0-9-_:./?]+)*|i";
- $string = preg_replace($pattern,'<a href="\0">\0</a>',$string);
- return $string;
- }
Subscribe to:
Posts (Atom)