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


PHP Arrays::inArray方法代码示例

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


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

示例1: getInfosMovie

 public static function getInfosMovie($id)
 {
     $html = dwn('http://vod.canalplay.com/films/cinema/holiday,297,308,' . $id . '.aspx');
     if (strstr($html, 'Object moved to')) {
         $url = 'http://vod.canalplay.com' . urldecode(Utils::cut('<h2>Object moved to <a href="', '"', $html));
         $html = dwn($url);
     }
     $story = Utils::cut('alt="L\'histoire" title="L\'histoire" /></h2><p>', '</p>', $html);
     $title = Utils::cut('var title="', '"', $html);
     $image = 'http://canalplay-publishing.canal-plus.com/movies/' . $id . '/pictures/' . $id . '_pivot.jpg';
     $purpose = Utils::cut('title="A propos du film" /></h2><p>', '</p></div></div>', $html);
     $distribution = array();
     $tab = explode("title=\"Voir tous les films de/avec '", $html);
     if (count($tab)) {
         for ($i = 1; $i < count($tab) - 1; $i++) {
             $seg = trim($tab[$i]);
             if (strstr($seg, "</a>") && strstr($seg, "underline")) {
                 $person = Utils::cut('\'">', '</a>', $seg);
                 if (!Arrays::inArray($person, $distribution)) {
                     $distribution[] = $person;
                 }
             }
         }
     }
     $director = null;
     $actors = array();
     if (count($distribution)) {
         $director = current($distribution);
         $actors = array();
         if (1 < count($distribution)) {
             for ($j = 1; $j < count($distribution); $j++) {
                 $actors[] = $distribution[$j];
             }
         }
     }
     $other = Utils::cut('<li style="clear:left;"><strong><br />', '</li>', $html);
     list($first, $second) = explode('</strong>- ', $other, 2);
     list($country, $year) = explode("-", $first, 2);
     $country = substr($country, 0, -1);
     $year = repl("\n", '', $year);
     $year = repl("\r", '', $year);
     $year = repl("\n", '', $year);
     list($duration, $dummy) = @explode("\n", $second, 2);
     $infos = array('title' => $title, 'story' => $story, 'image' => $image, 'purpose' => $purpose, 'director' => $director, 'actors' => $actors, 'country' => $country, 'year' => $year, 'duration' => $duration);
     return $infos;
 }
开发者ID:schpill,项目名称:thin,代码行数:46,代码来源:Allocine.php

示例2: __call

 public function __call($method, $args)
 {
     if (empty($this->_datas['foreignFields'])) {
         $this->_datas['foreignFields'] = array();
     }
     if (!Arrays::is($this->_datas['foreignFields'])) {
         $this->_datas['foreignFields'] = array($this->_datas['foreignFields']);
     }
     if (substr($method, 0, 3) == 'get') {
         $vars = array_values($this->fields());
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 3)));
         $var = Inflector::lower($uncamelizeMethod);
         if (Arrays::in($var, $vars) || ake($var, $this->_datas['foreignFields']) || true === $this->hasForeignRelation($var)) {
             if (ake($var, $this->_datas['foreignFields']) || true === $this->hasForeignRelation($var)) {
                 if (ake($var, $this->_datas['foreignFields']) && 'true' != $this->_datas['foreignFields'][$var]) {
                     return $this->_datas['foreignFields'][$var];
                 }
                 $var = true === $this->hasForeignRelation($var) ? $this->fkFieldName($var) : $var;
                 $rs = $this->_datas['configModel']['relationship'][$var];
                 $field = $rs['fieldName'];
                 $classModel = $this->_datas['classModel'];
                 $obj = new $classModel();
                 if (Arrays::inArray($field, $this->_datas['keys'])) {
                     $modelField = $rs['foreignTable'];
                     if (isset($this->_datas['configModel']['relationship']) && ake($field, $this->_datas['configModel']['relationship'])) {
                         $m = $this->_datas['configModel']['relationship'][$field];
                         if (ake("entity", $rs)) {
                             $entity = $rs['entity'];
                         } else {
                             $entity = $obj->_entity;
                         }
                         if (null !== $m['type']) {
                             switch ($m['type']) {
                                 case 'manyToOne':
                                 case 'oneToOne':
                                     $nObj = new self($entity, $modelField);
                                     if (ake("relationshipKeys", $rs)) {
                                         $field = $rs['relationshipKeys'];
                                     }
                                     if (!is_null($this->{$field})) {
                                         if (false === $this->_cache) {
                                             $result = $nObj->find($this->{$field});
                                         } else {
                                             $result = $nObj->cache($this->_cache)->find($this->{$field});
                                             $this->_cache = false;
                                         }
                                         $this->_datas['foreignFields'][$var] = $result;
                                         return $result;
                                     }
                                     break;
                                 case 'manyToMany':
                                 case 'oneToMany':
                                     $nObj = new self($entity, $modelField);
                                     $getter = $this->pk();
                                     $fk = ake("relationshipKeys", $rs) ? $rs['relationshipKeys'][$field] : $rs['foreignKey'];
                                     if (false === $this->_cache) {
                                         $result = $nObj->where($nObj->_dbName . '.' . $nObj->_tableName . "." . $fk . " = " . $nObj->quote($this->{$getter}))->select();
                                     } else {
                                         $result = $nObj->cache($this->_cache)->where($nObj->_dbName . '.' . $nObj->_tableName . "." . $fk . " = " . $nObj->quote($this->{$getter}))->select();
                                         $this->_cache = false;
                                     }
                                     $this->_datas['foreignFields'][$var] = $result;
                                     return $result;
                                     break;
                             }
                         }
                     }
                 }
             }
             if (isset($this->{$var}) || is_null($this->{$var})) {
                 return $this->{$var};
             } else {
                 throw new Exception("Unknown field {$var} in " . get_class($this) . " class.");
             }
         }
         return null;
     } elseif (substr($method, 0, 3) == 'set') {
         $vars = array_values($this->fields());
         $value = $args[0];
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 3)));
         $var = Inflector::lower($uncamelizeMethod);
         if (Arrays::in($var, $vars) || ake($var, $this->_datas['foreignFields']) || true === $this->hasForeignRelation($var)) {
             if (ake($var, $this->_datas['foreignFields']) || true === $this->hasForeignRelation($var)) {
                 $var = true === $this->hasForeignRelation($var) ? $this->fkFieldName($var) : $var;
                 $this->_datas['foreignFields'][$var] = $value;
                 $rs = $this->_datas['configModel']['relationship'][$var];
                 $setField = $rs['fieldName'];
                 $getter = $rs['foreignKey'];
                 if (Arrays::in($setField, $vars) && isset($value->{$getter})) {
                     $this->{$setField} = $value->{$getter};
                     return $this;
                 } else {
                     return $this;
                 }
             } else {
                 $this->{$var} = $value;
                 return $this;
             }
         } else {
             throw new Exception("Unknown field {$var} in " . get_class($this) . " class.");
//.........这里部分代码省略.........
开发者ID:schpill,项目名称:thin,代码行数:101,代码来源:Orm.php

示例3: option

 protected static function option($value, $display, $selected)
 {
     if (is_array($selected)) {
         $selected = Arrays::inArray($value, $selected) ? 'selected' : null;
     } else {
         $selected = (string) $value == (string) $selected ? 'selected' : null;
     }
     $attributes = array('value' => View::utf8($value), 'selected' => $selected);
     return '<option' . Html::attributes($attributes) . '>' . View::utf8($display) . '</option>';
 }
开发者ID:noikiy,项目名称:inovi,代码行数:10,代码来源:Form.php

示例4: get

 /**
  * Get a row of the cart by its ID
  *
  * @param  string $rowId The ID of the row to fetch
  * @return CartCollection
  */
 public function get($rowId)
 {
     $cart = $this->getContent();
     $rows = $cart->_fields;
     return Arrays::inArray($rowId, $rows) ? $cart->{$rowId} : null;
 }
开发者ID:schpill,项目名称:thin,代码行数:12,代码来源:Cart.php

示例5: auto

 /**
  * Perform auto inflection on an English word.
  *
  * @param  string  $value
  * @param  array   $source
  * @param  array   $irregular
  * @return string
  */
 protected function auto($value, $source, $irregular)
 {
     // If the word hasn't been cached, we'll check the list of words that
     // that are "uncountable". This should be a quick look up since we
     // can just hit the array directly for the value.
     if (Arrays::inArray(Inflector::lower($value), $this->config['uncountable'])) {
         return $value;
     }
     // Next, we will check the "irregular" patterns, which contain words
     // like "children" and "teeth" which can not be inflected using the
     // typically used regular expression matching approach.
     foreach ($irregular as $irregular => $pattern) {
         if (preg_match($pattern = '/' . $pattern . '$/i', $value)) {
             return preg_replace($pattern, $irregular, $value);
         }
     }
     // Finally we'll spin through the array of regular expressions and
     // and look for matches for the word. If we find a match we will
     // cache and return the inflected value for quick look up.
     foreach ($source as $pattern => $inflected) {
         if (preg_match($pattern, $value)) {
             return preg_replace($pattern, $inflected, $value);
         }
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:33,代码来源:Pluralizer.php

示例6: varIsObject

 function varIsObject($var)
 {
     $var_ser = serialize($var);
     array_push($this->arrHistory, $var_ser);
     $this->makeTableHeader("object", "object");
     if (is_object($var)) {
         $arrObjVars = get_object_vars($var);
         foreach ($arrObjVars as $key => $value) {
             $value = !is_object($value) && !Arrays::isArray($value) && trim($value) == "" ? "[empty string]" : $value;
             $this->makeTDHeader("object", $key);
             //check for recursion
             if (is_object($value) || Arrays::isArray($value)) {
                 $var_ser = serialize($value);
                 if (Arrays::inArray($var_ser, $this->arrHistory, TRUE)) {
                     $value = is_object($value) ? "*RECURSION* -> \$" . get_class($value) : "*RECURSION*";
                 }
             }
             if (Arrays::inArray(gettype($value), $this->arrType)) {
                 $this->checkType($value);
             } else {
                 echo $value;
             }
             echo $this->closeTDRow();
         }
         $arrObjMethods = get_class_methods(get_class($var));
         foreach ($arrObjMethods as $key => $value) {
             $this->makeTDHeader("object", $value);
             echo "[function]" . $this->closeTDRow();
         }
     } else {
         echo "<tr><td>" . $this->error("object") . $this->closeTDRow();
     }
     array_pop($this->arrHistory);
     echo "</table><hr class=thinDebugHr />";
 }
开发者ID:schpill,项目名称:thin,代码行数:35,代码来源:Info.php


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