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


PHP Arrays::end方法代码示例

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


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

示例1: getInfosPersonne

 public function getInfosPersonne($url)
 {
     $last = Arrays::last(explode('/', $url));
     $wp = redis()->get('wp.wp.info.' . $last);
     $html = redis()->get('wp.html.info.' . $last);
     if (!$wp) {
         $wp = file_get_contents($url);
         redis()->set('wp.wp.info.' . $last, $wp);
     }
     $url = 'http://fr.dbpedia.org/page/' . $last;
     $infos = [];
     $html = redis()->get('wp.info.' . $last);
     if (!$html) {
         $html = file_get_contents($url);
         redis()->set('wp.info.' . $last, $html);
     }
     $infos['completename'] = Utils::cut('<title ng:bind-template="{{about.title}} | DBpedia">', '</title>', $html);
     $infos['abstract'] = Utils::cut('<li><span class="literal"><span property="dbpedia-owl:abstract" xmlns:dbpedia-owl="http://dbpedia.org/ontology/">', '</span>', $html);
     $infos['image'] = Utils::cut('<li><span class="literal"><a class="uri" rel="dbpedia-owl:thumbnail nofollow" xmlns:dbpedia-owl="http://dbpedia.org/ontology/" href="', '"', $html);
     $infos['profession'] = Utils::cut('<li><span class="literal"><a class="uri" rel="dbpedia-owl:profession" xmlns:dbpedia-owl="http://dbpedia.org/ontology/" href="http://fr.dbpedia.org/resource/', '"', $html);
     $infos['birthname'] = Utils::cut('<li><span class="literal"><span property="dbpedia-owl:birthName" xmlns:dbpedia-owl="http://dbpedia.org/ontology/">', '</span>', $html);
     $birthdate = Utils::cut('<li><span class="literal"><span property="dbpedia-owl:birthDate" xmlns:dbpedia-owl="http://dbpedia.org/ontology/">', '</span>', $html);
     list($y, $m, $d) = explode('-', $birthdate, 3);
     $birthdate = "{$d}/{$m}/{$y}";
     $infos['birthdate'] = $birthdate;
     $deathdate = Utils::cut('<li><span class="literal"><span property="dbpedia-owl:deathDate" xmlns:dbpedia-owl="http://dbpedia.org/ontology/">', '</span>', $html);
     list($y, $m, $d) = explode('-', $deathdate, 3);
     $deathdate = "{$d}/{$m}/{$y}";
     $infos['deathdate'] = $deathdate != '//' ? $deathdate : null;
     // $tagsHtml = explode('ontology/" href="http://fr.dbpedia.org/resource/', $html);
     // array_shift($tagsHtml);
     // $tags = [];
     $wp = str_replace('<p><small>', '<small>', $wp);
     $wp = str_replace('<p><span', '<span>', $wp);
     $wpid = Utils::cut('"wgArticleId":', ',', $wp);
     $p = Utils::cut('<p>', '</p>', $wp);
     $infos['abstract'] = str_replace(["\n", "\r", "\t"], '', strip_tags($p));
     $infos['id_wp'] = (int) $wpid;
     if (strstr($wp, 'Profession</th')) {
         $tab = explode('Profession</th>', $wp);
         if (count($tab) > 1) {
             $seg = Utils::cut('<td>', '</td>', $tab[1]);
             if (strlen($seg)) {
                 $seg = str_replace(['<br />', '<br/>', '<br>'], ', ', $seg);
                 $infos['profession'] = strip_tags($seg);
             }
         }
     } else {
         if (strstr($wp, 'Activité principale</th')) {
             $tab = explode('Activité principale</th', $wp);
             if (count($tab) > 1) {
                 $seg = Utils::cut('<td>', '</td>', $tab[1]);
                 if (strlen($seg)) {
                     $seg = str_replace(['<br />', '<br/>', '<br>'], ', ', $seg);
                     $infos['profession'] = strip_tags($seg);
                 }
             }
         }
     }
     // foreach ($tagsHtml as $tagHtml) {
     //     list($tag, $dummy) = explode('">', $tagHtml, 2);
     //     if (!fnmatch('*:*', $tag) && !is_numeric($tag)) {
     //         $tags[] = $tag;
     //     }
     // }
     if (fnmatch('http*', $infos['completename'])) {
         $infos['completename'] = ucwords(str_replace('_', ' ', Arrays::end(explode('/', $infos['completename']))));
     }
     $app = $this->getApp($last);
     $media = array_get($app, 'lead.media');
     if (is_array($media)) {
         $items = isAke($media, 'items', []);
         if (!empty($items)) {
             $item = current($items);
             $infos['image'] = isAke($item, 'url', false);
         }
     }
     if (!isset($infos['image'])) {
         $infos['image'] = $this->getImage((int) $wpid);
     }
     if (!$infos['image']) {
         $infos['image'] = $this->getImage((int) $wpid);
     }
     $infos['abstract'] = str_replace(['[1]', '[2]', '[3]', '[4]', '[5]'], '', $infos['abstract']);
     $infos['abstract'] = $this->getExtract((int) $wpid);
     // $tags = array_unique($tags);
     // asort($tags);
     // $infos['tags'] = array_values($tags);
     return $infos;
 }
开发者ID:schpill,项目名称:standalone,代码行数:90,代码来源:wikipedia.php

示例2: fiche

 public function fiche($reseller_id)
 {
     $user = session('user')->getUser();
     if (!$user) {
         $user = [];
     }
     $account_id = (int) isAke($user, 'id', 23);
     $fiche = Model::Restodata()->where(['reseller_id', '=', (int) $reseller_id])->first(true);
     /* c'est un restaurateur */
     if ($fiche) {
         $row = $fiche->toArray();
         $data = [];
         $options = $row['options'];
         $preferences_client_paiement_titre = isAke($options, 'preferences_client_paiement_titre', false);
         $data['paiement_cheque_montant_max'] = isAke($options, 'preferences_client_paiement_cheque_montant_max', 0);
         $data['paiement_carte'] = isAke($options, 'preferences_client_paiement_carte', -1);
         $data['paiement_titre_rendu_monnaie'] = isAke($options, 'preferences_client_paiement_titre_rendu_monnaie', $preferences_client_paiement_titre ? 0 : -1);
         $data['paiement_titre_max_accepte'] = isAke($options, 'preferences_client_paiement_titre_max_accepte', null);
         $data['company'] = $row['company'];
         $data['company']['siret'] = (string) isAke($row['company'], 'siret', '');
         $data['company']['tel'] = (string) str_replace([" ", ".", "-", "+"], ["", "", "", "00"], isAke($row['company'], 'tel', ''));
         if (fnmatch('0*', $data['company']['tel'])) {
             $data['company']['tel'] = strReplaceFirst('0', '+33', $data['company']['tel']);
         }
         $data['is_favorite'] = lib('favorite')->has('reseller', (int) $reseller_id, (int) $account_id);
         $data['is_resto'] = true;
         $data['nombre_places'] = $options['nombre_places'];
         $data['nombre_places_terrasse'] = $options['nombre_places_terrasse'];
         $horaires = [];
         $schedules = $row['schedules'];
         foreach ($schedules as $typeSchedule => $days) {
             if (!isset($horaires[$typeSchedule])) {
                 $horaires[$typeSchedule] = [];
             }
             foreach ($days as $day => $dataSchedule) {
                 if (!isset($horaires[$typeSchedule][$day])) {
                     $horaires[$typeSchedule][$day] = [];
                 }
                 foreach ($dataSchedule as $when => $hour) {
                     $hour = str_replace('_', 'h', $hour);
                     $horaires[$typeSchedule][$day][$when] = str_replace('h00', 'h', $hour);
                 }
             }
         }
         $data['horaires'] = $horaires;
         $prefsResto = array_keys(lib('resto')->extractPreferences($options));
         $activitesResto = array_keys(lib('resto')->extractActivites($options));
         $labelsResto = array_keys(lib('resto')->extractLabels($options));
         $thematiquesResto = array_keys(lib('resto')->extractThematiques($options));
         $guidesResto = array_keys(lib('resto')->extractGuides($options));
         $optionsMacro = (include APPLICATION_PATH . DS . 'models/options/413.php');
         $valuesGuides = array_get($optionsMacro, 'guides.values');
         $valuesActivities = array_get($optionsMacro, 'activites.values');
         $themes_affil = array_get($optionsMacro, 'activites.types_affil');
         $valuesThematiques = [];
         $valuesThematiques = array_merge($valuesThematiques, array_get($optionsMacro, 'thematiques.values_0'));
         $valuesThematiques = array_merge($valuesThematiques, array_get($optionsMacro, 'thematiques.values_1'));
         $valuesThematiques = array_merge($valuesThematiques, array_get($optionsMacro, 'thematiques.values_2'));
         $valuesThematiques = array_merge($valuesThematiques, array_get($optionsMacro, 'thematiques.values_3'));
         $valuesLabels = [];
         $valuesLabels = array_merge($valuesLabels, array_get($optionsMacro, 'labels.values_0'));
         $valuesLabels = array_merge($valuesLabels, array_get($optionsMacro, 'labels.values_1'));
         $acts = $themes = $lbls = $prefs = $guides = [];
         foreach ($guidesResto as $guidesId) {
             $guides[] = $valuesGuides[(int) str_replace('guides_', '', $guidesId)];
         }
         foreach ($activitesResto as $activiteId) {
             if (fnmatch('*_*_*', $activiteId)) {
                 continue;
             }
             $acts[] = $valuesActivities[(int) str_replace('activites_', '', $activiteId)];
         }
         foreach ($thematiquesResto as $thematiquesId) {
             $ind = str_replace('thematiques_', 'thematiques.values_', $thematiquesId);
             $last = Arrays::end(explode('_', $ind));
             $ind = str_replace('_' . $last, '.' . $last, $ind);
             $ind = str_replace('thematiques.values.', 'thematiques.values_', $ind);
             $val = array_get($optionsMacro, $ind);
             $themes[] = $val;
         }
         foreach ($labelsResto as $labelsId) {
             $ind = str_replace('labels_', 'labels.values_', $labelsId);
             $last = Arrays::end(explode('_', $ind));
             $ind = str_replace('_' . $last, '.' . $last, $ind);
             $ind = str_replace('labels.values.', 'labels.values_', $ind);
             $val = array_get($optionsMacro, $ind);
             $lbls[] = $val;
         }
         // foreach ($labelsResto as $labelsId) {
         //     $lbls[] = $valuesLabels[(int) str_replace('thematiques_', '', $labelsId)];
         // }
         foreach ($prefsResto as $index) {
             $tab = explode('_', $index);
             if (is_numeric(end($tab))) {
                 if (!isset($prefs[str_replace(['preferences_client_', '_' . end($tab)], '', $index)])) {
                     $prefs[str_replace(['preferences_client_', '_' . end($tab)], '', $index)] = [];
                 }
                 $values = array_get($optionsMacro, str_replace('_' . end($tab), '', $index) . '.values');
                 $prefs[str_replace(['preferences_client_', '_' . end($tab)], '', $index)][] = $values[end($tab)];
             }
//.........这里部分代码省略.........
开发者ID:schpill,项目名称:standalone,代码行数:101,代码来源:myzelift.php


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