本文整理汇总了PHP中normalize函数的典型用法代码示例。如果您正苦于以下问题:PHP normalize函数的具体用法?PHP normalize怎么用?PHP normalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了normalize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: youtubeSearch
function youtubeSearch($title)
{
$trailers = array();
$title = normalize($title);
$trailerquery = $title . " trailer";
$youtubeurl = "http://gdata.youtube.com/feeds/api/videos?client=" . YOUTUBE_CLIENT_ID . "&key=" . YOUTUBE_DEVELOPER_KEY . "&v=2&" . "q=" . urlencode($trailerquery) . "&start-index=1&max-results=10";
$resp = httpClient($youtubeurl, true);
if (!$resp['success']) {
return $trailers;
}
$xml = simplexml_load_string($resp['data']);
// obtain namespaces
$namespaces = $xml->getNameSpaces(true);
foreach ($xml->entry as $trailer) {
$media = $trailer->children($namespaces['media']);
$yt = $media->group->children($namespaces['yt']);
$id = $yt->videoid;
// API filtering code removed
$trailers[] = array('id' => (string) $id, 'src' => (string) $trailer->content['src'], 'title' => (string) $trailer->title);
if (count($trailers) >= 10) {
break;
}
}
return $trailers;
}
示例2: slug
function slug($str, $separator = '-')
{
$str = normalize($str);
// replace non letter or digits by separator
$str = preg_replace('#^[^A-z0-9]+$#', $separator, $str);
return trim(strtolower($str), $separator);
}
示例3: render_child
/**
* Overrides the method to render the child in a `<DIV.field>` wrapper:
*
* ```html
* <div class="field [{normalized_field_name}][required]">
* [<label for="{element_id}" class="input-label [required]">{element_form_label}</label>]
* <div class="input">{child}</div>
* </div>
* ```
*
* @inheritdoc
*/
protected function render_child($child)
{
$control_group_class = 'control-group';
$name = $child['name'];
if ($name) {
$control_group_class .= ' control-group--' . normalize($name);
}
if ($child[self::REQUIRED]) {
$control_group_class .= ' required';
}
$state = $child[Element::STATE];
if ($state) {
$control_group_class .= ' ' . $state;
}
$label = $child[Form::LABEL];
if ($label) {
if (!$label instanceof Element) {
$label = $this->t($label, [], ['scope' => 'group.label', 'default' => $this->t($label, [], ['scope' => 'element.label'])]);
}
$label = '<label for="' . $child->id . '" class="controls-label">' . $label . '</label>' . PHP_EOL;
}
return <<<EOT
<div class="{$control_group_class}">
\t{$label}<div class="controls">{$child}</div>
</div>
EOT;
}
示例4: slug
function slug($str, $separator = '-')
{
$str = normalize($str);
// replace non letter or digits by separator
$str = preg_replace('/[^a-zA-Z0-9]+/', $separator, html_entity_decode($str, ENT_QUOTES));
return trim(strtolower($str), $separator);
}
示例5: plug_chat
function plug_chat($p, $msg, $res = '')
{
//$_SESSION['muse']='';
$p = $p ? normalize($p) : 'public';
ses('muse', $res ? ajxg($res) : ses('USE'));
return chatform($p, $msg) . divd('cht' . $p, chatread($p));
}
示例6: env
/**
* @param string $key
* @param mixed $default
* @return mixed
*/
function env($key, $default = null)
{
$value = getenv($key);
if ($value === false) {
return value($default);
}
return normalize($value);
}
示例7: rednm
function rednm($d)
{
if (strrpos($d, "/") !== false) {
$d = substr($d, strrpos($d, "/") + 1);
}
//if(strrpos($d,".")!==false)$d=substr($d,0,strpos($d,"."));
return normalize($d);
}
示例8: cameraTransform
function cameraTransform($C, $A)
{
$w = normalize(addVector($C, scalarProduct($A, -1)));
$y = array(0, 1, 0);
$u = normalize(crossProduct($y, $w));
$v = crossProduct($w, $u);
$t = scalarProduct($C, -1);
return array($u[0], $v[0], $w[0], 0, $u[1], $v[1], $w[1], 0, $u[2], $v[2], $w[2], 0, dotProduct($u, $t), dotProduct($v, $t), dotProduct($w, $t), 1);
}
示例9: testNormalizeCase
/**
*
*/
public function testNormalizeCase()
{
$test1 = 'slug-case-to-normal-case';
$test2 = 'snake_case_to_normal_case';
$test3 = 'camelCaseToNormalCase';
$test4 = 'CamelCaseToNormalCase';
$this->assertEquals(normalize($test1), 'Slug case to normal case');
$this->assertEquals(normalize($test2), 'Snake case to normal case');
$this->assertEquals(normalize($test3), 'Camel case to normal case');
$this->assertEquals(normalize($test4), 'Camel case to normal case');
}
示例10: mform_mr
function mform_mr($d)
{
$r = explode(",", $d);
$n = count($r);
for ($i = 0; $i < $n; $i++) {
list($v, $type) = explode("=", $r[$i]);
$vb = normalize($v);
if ($type != 'button') {
$rb[] = $vb;
}
}
//$rb[]='day';
return $rb;
}
示例11: testword
function testword()
{
require "../includes/connect.php";
require "../includes/string.php";
//$name = str_replace($unwantedChars, "", $row['movieId']);
//$hashtag = "#".$name;
//rpp = tweetcount (max= 100)
$tweetUrl = "http://tweets2csv.com/results.php?q=%23starwars&rpp=40&submit=Search";
echo $tweetUrl . "<br>";
$htmltext = file_get_contents($tweetUrl);
$regex = "#<div class='user'>(.*)(\\s*)<div class='text'>(.*)<div class='description'>#";
preg_match_all($regex, $htmltext, $matches, PREG_SET_ORDER);
$wordArray = array();
$unwantedChars = array('/', "\\", 'http', "@", "-", "<a");
foreach ($matches as $tweet) {
//'text'=>$tweet[3],
//$newData = array("text"=>htmlentities($tweet[3]));
//array_push($data["data"], $newData);
//echo $tweet[3]."<br>";
$words = explode(" ", $tweet[3]);
foreach ($words as $word) {
if (!contains($word, $unwantedChars) && !in_array(normalize($word), $stopwords)) {
if (!isset($wordArray[$word])) {
$wordArray[$word] = 1;
} else {
$wordArray[$word]++;
}
}
}
}
$newFileName = '../words/starwars.txt';
if (file_put_contents($newFileName, json_encode($wordArray)) != false) {
echo "added";
} else {
echo "Cannot create file (" . basename($newFileName) . ")";
}
echo "<br>";
//format (just split by / and :)
/*$newFileName = '../sentiment/'.$name.".txt";
$appendContent = $sent['positive'].";".$sent['negative'].";".$sent['neutral'].";".$sent['tweetCount'].";".$updateDate."/";
//If filename does not exist, the file is created. Otherwise, the existing file is overwritten, unless the FILE_APPEND flag is set.
if(file_put_contents($newFileName,$appendContent, FILE_APPEND) !=false){
echo "File created (".basename($newFileName).")";
}else{
echo "Cannot create file (".basename($newFileName).")";
}*/
}
示例12: prepare_link
function prepare_link($title, $slug)
{
//if not allowed characters
$link = normalize($title);
//multiples whitespaces -> single whitespace
$link = preg_replace("/[^a-zA-Z0-9-\\s]+/i", "", $link);
$link = trim($link);
$link = strtolower($link);
//multiples whitespaces -> single minus sign
$link = preg_replace("/\\s\\s+/i", " ", $link);
$link = preg_replace("/--+/i", "-", $link);
$link = preg_replace("/\\s/i", "-", $link);
$link = '/' . $slug . '/' . $link;
return $link;
}
示例13: downloadPoster
function downloadPoster($movieId, $posterUrl)
{
//require("includes/connect.php");
set_time_limit(3600);
$filename = normalize($movieId);
$file = '../poster/' . $filename . '.jpg';
if (!empty($posterUrl)) {
echo $file . "made <br>";
if (!file_exists($file)) {
copy($posterUrl, $file);
} else {
echo "already exists";
}
} else {
echo "EMPTY <br>";
}
}
示例14: addf_inject
function addf_inject()
{
calltar();
$ra = msql_read('server', 'edition_typos', '');
if ($ra) {
$vra = array_keys_r($ra, 0, 'k');
}
$r = msql_read('', 'public_addfonts', '');
if ($r) {
$vr = array_shift($r);
}
$dir = 'fonts/';
$diru = 'users/' . $_SESSION['qb'] . '/fonts/';
if (!is_dir($diru)) {
mkdir($diru);
}
if ($r) {
foreach ($r as $k => $v) {
$font = normalize($v[0]);
if (!$vra[$font]) {
$rb = array($font, '', '', '', '');
for ($i = 1; $i < count($v); $i++) {
$f = $font . '.' . $vr[$i];
$rc[] = $dir . $f;
$ret .= addf_copy($v[$i], $dir . $f) . br();
}
//u
//msql_modif('server','edition_typos',$rb,$dfb,'push','');
//modif_vars('','public_addfonts',$k,'del');
if ($rc) {
PclTarCreate($diru . $font . '.tar.gz', $rc, '', '', '');
}
$ret .= btn('txtblc', lka($diru . $font . '.tar.gz')) . ' ' . btn('txtx', 'saved') . br();
} else {
$ret .= $font . ' already_exists' . br();
}
}
}
//if($rb)msql_modif('server','edition_typos',$rb,$dfb,'add','');
$ret .= lkc('txtbox', '/?admin=fonts&inject==', 'inject datas (admin/fonts)') . br();
return $ret;
}
示例15: vernam_enkripsi
function vernam_enkripsi($plain, $key)
{
$n = strlen($plain);
for ($i = 0; $i < $n; $i++) {
$data[$i] = str_pad(decbin(ord($plain[$i])), 8, "0", STR_PAD_LEFT);
$kunci[$i] = str_pad(decbin(ord($key[$i])), 8, "0", STR_PAD_LEFT);
//echo 'biner data ='.str_pad(decbin(ord($plain[$i])), 8, "0", STR_PAD_LEFT).', biner kunci = '.str_pad(decbin(ord($key[$i])), 8, "0", STR_PAD_LEFT).' ';
//opeasi xor
for ($j = 0; $j < 8; $j++) {
$hasil[$j] = ($data[$i][$j] + $kunci[$i][$j]) % 2;
}
$result[$i] = implode($hasil);
//echo 'biner hasil = '.$result[$i];
$chiper[$i] = chr(normalize(bindec($result[$i])));
//echo ', biner chiper = '.$chiper[$i];
//echo ' '.ord($plain[$i]).', key ='.ord($key[$i]).', hasil = '.bindec($result[$i]).', normalisasi ='.normalize(bindec($result[$i])).'<br/>';
}
$chiperKey = implode($chiper);
return $chiperKey;
}