| | 32 | * Cleans up the given string and decodes and transliterates a UTF-8 string |
|---|
| | 33 | * into corresponding ASCII characters |
|---|
| | 34 | * |
|---|
| | 35 | * @return string |
|---|
| | 36 | */ |
|---|
| | 37 | private function decode($str) |
|---|
| | 38 | { |
|---|
| | 39 | $str = str_replace( '—', '-', $str); |
|---|
| | 40 | $str = trim(preg_replace(array('/<[^>]+>/ms', '/\s+/ms'), array( '', ' ' ), $str)); |
|---|
| | 41 | return $this->decodeTranslit($str); |
|---|
| | 42 | } |
|---|
| | 43 | |
|---|
| | 44 | /** |
|---|
| 41 | | $name = str_replace('_', '-', $function); |
|---|
| 42 | | $contents = file_get_contents('http://php.net/manual/en/function.' . rtrim($name, '();') . '.php'); |
|---|
| 43 | | $start = strpos($contents, '<div class="methodsynopsis dc-description">'); |
|---|
| 44 | | $end = strpos($contents, '</div>', $start); |
|---|
| 45 | | $contents = substr($contents, $start, $end-$start); |
|---|
| 46 | | $contents = preg_replace(array('/<[^>]+>/ms', '/\s+/ms'), array('', ' '), $contents); |
|---|
| 47 | | $contents = trim(str_replace(' ,', ',', $contents)); |
|---|
| | 54 | $name = str_replace(array('_', ' '), '-', $function); |
|---|
| | 55 | $tmp = file_get_contents('http://php.net/manual/en/function.' . rtrim($name, '();') . '.php'); |
|---|
| | 56 | if( strpos( $tmp, '<p class="refpurpose dc-title">' ) !== false ) { |
|---|
| | 57 | $contents = '[ '.$this->tinyUrl('http://php.net/'.$name).' ] '; |
|---|
| | 58 | if (preg_match( '/<div class="methodsynopsis dc-description">(.*?)<\/div>/mis', $tmp, $m)) { |
|---|
| | 59 | $contents .= $this->_clean($m[1]); |
|---|
| | 60 | } |
|---|
| | 61 | if (preg_match( '/<p class="refpurpose dc-title">(.*?)<\/p>/mis', $tmp, $m)) { |
|---|
| | 62 | $m = explode( '-', $this->_clean($m[1]), 2); |
|---|
| | 63 | $contents .= ' - '.$m[1]; |
|---|
| | 64 | } |
|---|
| | 65 | $contents = trim(str_replace(' ,', ',', $contents)); |
|---|
| | 66 | } |
|---|
| | 67 | else { |
|---|
| | 68 | $contents = 'Nothing found'; |
|---|
| | 69 | } |
|---|