当前位置: 首页>>代码示例>>PHP>>正文


PHP pts_strings::proximity_match方法代码示例

本文整理汇总了PHP中pts_strings::proximity_match方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_strings::proximity_match方法的具体用法?PHP pts_strings::proximity_match怎么用?PHP pts_strings::proximity_match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pts_strings的用法示例。


在下文中一共展示了pts_strings::proximity_match方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: read_sun_ddu_dmi_info

 public static function read_sun_ddu_dmi_info($find_objects, $args = null)
 {
     // Read Sun's Device Driver Utility for OpenSolaris
     $values = array();
     if (in_array(phodevi::read_property('system', 'kernel-architecture'), array('i686', 'x86_64'))) {
         $dmi_info = '/usr/ddu/bin/i386/dmi_info';
     } else {
         $dmi_info = '/usr/ddu/bin/sparc/dmi_info';
     }
     if (is_executable($dmi_info) || is_executable($dmi_info = '/usr/ddu/bin/dmi_info')) {
         $info = shell_exec($dmi_info . ' ' . $args . ' 2>&1');
         $lines = explode("\n", $info);
         $find_objects = pts_arrays::to_array($find_objects);
         for ($i = 0; $i < count($find_objects) && count($values) == 0; $i++) {
             $objects = pts_strings::comma_explode($find_objects[$i]);
             $this_section = null;
             if (count($objects) == 2) {
                 $section = $objects[0];
                 $object = $objects[1];
             } else {
                 $section = null;
                 $object = $objects[0];
             }
             foreach ($lines as $line) {
                 $line = pts_strings::colon_explode($line);
                 $line_object = isset($line[0]) ? str_replace(' ', null, $line[0]) : null;
                 $this_value = count($line) > 1 ? $line[1] : null;
                 if (empty($this_value) && !empty($section)) {
                     $this_section = $line_object;
                 }
                 if ($line_object == $object && ($this_section == $section || pts_strings::proximity_match($section, $this_section)) && !empty($this_value) && $this_value != 'Unknown') {
                     array_push($values, $this_value);
                 }
             }
         }
     }
     return $values;
 }
开发者ID:ShaolongHu,项目名称:phoronix-test-suite,代码行数:38,代码来源:phodevi_solaris_parser.php

示例2: read_amd_pcsdb_direct_parser

 public static function read_amd_pcsdb_direct_parser($attribute, $find_once = false)
 {
     // Read AMD's AMDPCSDB, AMD Persistent Configuration Store Database but using our own internal parser instead of relying upon aticonfig/amdconfig
     $amdpcsdb_file = null;
     $last_found_section_count = -1;
     $this_section_count = 0;
     $attribute_values = array();
     $attribute = pts_strings::comma_explode($attribute);
     if (count($attribute) == 2) {
         $attribute_prefix = array_reverse(explode('/', $attribute[0]));
         $attribute_key = $attribute[1];
         $is_in_prefix = false;
         if (is_file('/etc/ati/amdpcsdb')) {
             $amdpcsdb_file = explode("\n", file_get_contents('/etc/ati/amdpcsdb'));
         }
         for ($l = 0; $l < count($amdpcsdb_file) && ($find_once == false || $last_found_section_count == -1); $l++) {
             $line = trim($amdpcsdb_file[$l]);
             if (substr($line, 0, 1) == '[' && substr($line, -1) == ']') {
                 // AMDPCSDB Header
                 $prefix_matches = true;
                 $header = array_reverse(explode('/', substr($line, 1, -1)));
                 for ($i = 0; $i < count($attribute_prefix) && $i < count($header) && $prefix_matches; $i++) {
                     if ($attribute_prefix[$i] != $header[$i] && pts_strings::proximity_match($attribute_prefix[$i], $header[$i]) == false) {
                         $prefix_matches = false;
                     }
                 }
                 if ($prefix_matches) {
                     $is_in_prefix = true;
                     $this_section_count++;
                 } else {
                     $is_in_prefix = false;
                 }
             } else {
                 if ($is_in_prefix && $this_section_count != $last_found_section_count && count($key_components = explode('=', $line)) == 2) {
                     // AMDPCSDB Value
                     if ($key_components[0] == $attribute_key) {
                         $value_type = substr($key_components[1], 0, 1);
                         $value = substr($key_components[1], 1);
                         switch ($value_type) {
                             case 'V':
                                 // Value
                                 if (is_numeric($value) && strlen($value) < 9) {
                                     $value = dechex($value);
                                     $value = '0x' . str_repeat(0, 8 - strlen($value)) . strtoupper($value);
                                 }
                                 break;
                             case 'R':
                                 // Raw
                                 break;
                             case 'S':
                                 // String
                                 break;
                         }
                         array_push($attribute_values, $value);
                         $last_found_section_count = $this_section_count;
                     }
                 }
             }
         }
     }
     if (count($attribute_values) == 0) {
         $attribute_values = null;
     } else {
         if (count($attribute_values) == 1) {
             $attribute_values = $attribute_values[0];
         }
     }
     return $attribute_values;
 }
开发者ID:rkingsbury,项目名称:phoronix-test-suite,代码行数:69,代码来源:phodevi_linux_parser.php


注:本文中的pts_strings::proximity_match方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。