本文整理汇总了PHP中Str_replace函数的典型用法代码示例。如果您正苦于以下问题:PHP Str_replace函数的具体用法?PHP Str_replace怎么用?PHP Str_replace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Str_replace函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showTitle
public function showTitle($context_in)
{
$title = $context_in->getBook()->getTitle();
$this->titleCount++;
if (1 < $this->titleCount) {
$context_in->setTitleState(new BookTitleStateExclaim());
}
return Str_replace(' ', '*', $title);
}
示例2: setStarsOff
function setStarsOff()
{
$this->setAuthor(Str_replace('*', ' ', $this->getAuthor()));
$this->setTitle(Str_replace('*', ' ', $this->getTitle()));
}
示例3: mp3_id
//.........这里部分代码省略.........
// now convert those four bytes to BIN. maybe it can be faster and easier. dunno how yet. help?
for ($y = 0; $y < 4; $y++) {
$x = decbin(ord($tmp[$y]));
for ($i = 0; $i < 8 - StrLen($x); $i++) {
$x .= "0";
}
$bajt .= $x;
}
// every mp3 framesynch begins with eleven ones, lets look for it. if not found continue looking for some 1024 bytes (you can search multiple for it or you can disable this, it will speed up and not many mp3 are like this. anyways its not standart)
// if(substr($bajt,1,11)!="11111111111") {
// return -1;
// break;
// }
if (substr($bajt, 1, 11) != "11111111111") {
fseek($f, 4);
$tmp = fread($f, 2048);
for ($i = 0; $i < 2048; $i++) {
if (ord($tmp[$i]) == 255 && substr(decbin(ord($tmp[$i + 1])), 0, 3) == "111") {
$tmp = substr($tmp, $i, 4);
$bajt = "";
for ($y = 0; $y < 4; $y++) {
$x = decbin(ord($tmp[$y]));
for ($i = 0; $i < 8 - StrLen($x); $i++) {
$x .= "0";
}
$bajt .= $x;
}
break;
}
}
}
if ($bajt == "") {
return -1;
break;
}
// now parse all the info from frame header
$len = filesize($file);
$idtag["version"] = $version[substr($bajt, 11, 2)];
$idtag["layer"] = $layer[substr($bajt, 13, 2)];
$idtag["crc"] = $crc[$bajt[15]];
$idtag["bitrate"] = $bitrate[substr($bajt, 16, 4)][$bitindex[substr($bajt, 11, 4)]];
$idtag["frequency"] = $freq[substr($bajt, 20, 2)][substr($bajt, 11, 2)];
$idtag["padding"] = $copy[$bajt[22]];
$idtag["mode"] = $mode[substr($bajt, 24, 2)];
$idtag["copyright"] = $copy[$bajt[28]];
$idtag["original"] = $copy[$bajt[29]];
// lets count lenght of the song
if ($idtag["layer"] == 1) {
$fsize = (12 * ($idtag["bitrate"] * 1000) / $idtag["frequency"] + $idtag["padding"]) * 4;
} else {
$fsize = 144 * ($idtag["bitrate"] * 1000 / $idtag["frequency"] + $idtag["padding"]);
}
// Modified by Luca (18/02/01): devel@lluca.com
$idtag["lenght_sec"] = round($len / Round($fsize) / 38.37);
// end
$idtag["lenght"] = date("i:s", round($len / Round($fsize) / 38.37));
// now lets see at the end of the file for id3 tag. if exists then parse it. if file doesnt have an id 3 tag if will return -1 in field 'tag' and if title is empty it returns file name.
if (!$len) {
$len = filesize($file);
}
fseek($f, $len - 128);
$tag = fread($f, 128);
if (Substr($tag, 0, 3) == "TAG") {
$idtag["file"] = $file;
$idtag["tag"] = -1;
// Modified by Luca (18/02/01): devel@lluca.com
$idtag["title"] = Mp3Parser::strip_nulls(Substr($tag, 3, 30));
$idtag["artist"] = Mp3Parser::strip_nulls(Substr($tag, 33, 30));
$idtag["album"] = Mp3Parser::strip_nulls(Substr($tag, 63, 30));
$idtag["year"] = Mp3Parser::strip_nulls(Substr($tag, 93, 4));
$idtag["comment"] = Mp3Parser::strip_nulls(Substr($tag, 97, 30));
// If the comment is less than 29 chars, we look for the presence of a track #
if (strlen($idtag["comment"]) < 29) {
if (Ord(Substr($tag, 125, 1)) == chr(0)) {
// If char 125 is null then track (maybe) is present
$idtag["track"] = Ord(Substr($tag, 126, 1));
} else {
// If not, we are sure is not present.
$idtag["track"] = 0;
}
} else {
// If the comment is 29 or 30 chars long, there's no way to put track #
$idtag["track"] = 0;
}
// end
$idtag["genreid"] = Ord(Substr($tag, 127, 1));
$idtag["genre"] = $genres[$idtag["genreid"]];
$idtag["filesize"] = $len;
} else {
$idtag["tag"] = 0;
}
// close opened file and return results.
if (!$idtag["title"]) {
$idtag["title"] = Str_replace("\\", "/", $file);
$idtag["title"] = substr($idtag["title"], strrpos($idtag["title"], "/") + 1, 255);
}
fclose($f);
return $idtag;
}
}
示例4: showTitle
public function showTitle($book_in)
{
$title = $book_in->getTitle();
$this->titleCount++;
return Str_replace(' ', '*', $title);
}
示例5: fetch
public function fetch($fetch)
{
$array = mysql_fetch_array($fetch);
return $this->query = Str_replace(" ", " ", $array);
}
示例6: starTitle
function starTitle()
{
$this->btd->title = Str_replace(" ", "*", $this->btd->title);
}
示例7: file_get_contents
<?php
$link = $_GET["link"];
$html = file_get_contents($link);
$t1 = explode('<meta name="title" content="', $html);
$t2 = explode('-', $t1[1]);
$titulek = $t2[0];
$t1 = explode('<link rel="image_src" href="', $html);
$t2 = explode('"', $t1[1]);
$nahled = $t2[0];
echo "<mediaDisplay>\r\n <text offsetXPC=55 offsetYPC=6 widthPC=50 heightPC=6 fontSize=20 backgroundColor=-1:-1:-1 foregroundColor=250:250:250>:{$titulek}</text>\t\t\t\r\n </mediaDisplay>\n";
echo "<channel>\r\n\t<title>Stream.cz</title>\n";
$t1 = explode('<meta name="description" content="', $html);
$t2 = explode('"', $t1[1]);
$popis1 = $t2[0];
$popis = Str_replace("&", "-", $popis1);
$t1 = explode('<div id="videoDescription">', $html);
$t2 = explode('-', $t1[1]);
$datum = $t2[0];
$t1 = explode('&cdnHQ=', $html);
$t2 = explode('&', $t1[1]);
$hq = $t2[0];
$t1 = explode('&cdnLQ=', $html);
$t2 = explode('&', $t1[1]);
$lq = $t2[0];
$t1 = explode('&cdnHD=', $html);
$t2 = explode('&', $t1[1]);
$hd = $t2[0];
if ($hd != "") {
$lhd = "http://cdn-dispatcher.stream.cz/getSource?id=" . $hd . "&proto=rtmp";
$html2 = file_get_contents($lhd);
示例8: while
//echo "<th>CustPW</th></tr>\n";
/* fetch object array */
while ($row = $result->fetch_row()) {
// printf ("%s (%s)\n", $row[0], $row[1]);
//echo "<tr><th>{$row[0]}</th>";
if ($Swap == "N") {
echo Str_replace("_", " ", $row[1]);
//echo $row[1]; ///Cust FName
echo " ";
echo Str_replace("_", " ", $row[2]);
//echo $row[2]; //CustLName
} else {
echo Str_replace("_", " ", $row[2]);
//echo $row[2]; ///Cust FName
echo " ";
echo Str_replace("_", " ", $row[1]);
//echo $row[1]; //CustLName
}
echo "<br>Email: ";
//echo "{$row[3]}";
//echo "<th>{$row[3]}</th>";
//echo "{$row[4]}";
echo "{$row[5]}";
// Cust Email FROM CUSTOMER TABLE!!!
$E = $row[5];
//echo "{$row[6]}";
//echo "<th>{$row[7]}</th>";
//echo "<th>{$row[8]}</th>";
//echo "<th>{$row[9]}</th></tr>\n";
//$P = $row[9];
/*echo "row5: {$row[5]}";
示例9: explode
$disk = $queryArr[1];
}
$URL = "http://www.ceskatelevize.cz/ivysilani/" . $lnk;
echo "<?xml version='1.0' ?>\n";
echo "<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
if (($html = openpage($URL)) != FALSE) {
$ItemsOut .= "<channel>\n<title>ČT iVysílání</title>";
$videos = explode('<li class="itemBlock clearfix">', $html);
unset($videos[0]);
$videos = array_values($videos);
foreach ($videos as $video) {
$t1 = explode(' href="', $video);
$t2 = explode('"', $t1[1]);
$link = "http://www.ceskatelevize.cz" . $t2[0];
$t1 = explode('src="', $video);
$t2 = explode('"', $t1[1]);
$nahled = $t2[0];
$t1 = explode('alt="', $video);
$t2 = explode('"', $t1[1]);
$titulek = $t2[0];
if (strpos($titulek, '<') != false) {
$titulek = "Bezejmenný titul";
}
$titulek2 = Str_replace("—", "-", $titulek);
$ItemsOut .= "\r\n\t\t\t<item>\r\n\t\t\t\t<title>" . $titulek2 . "</title>\r\n\t\t\t\t<link>http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . "/ct_link.php?link=" . $link . "</link>\r\n\t\t\t\t<media:thumbnail url=\"" . $nahled . "\" />\r\n\t\t\t</item>\n";
}
$ItemsOut .= "</channel>\n</rss>";
echo $ItemsOut;
} else {
echo "TEST SELHAL !";
}
示例10: processTitle
function processTitle($title)
{
return Str_replace(' ', '*', $title);
}
示例11: showTitle
function showTitle($title_in)
{
return Str_replace(" ", "*", $title_in);
}
示例12: getCURL
private function getCURL($url)
{
$url = Str_replace(" ", "+", $url);
//to have no problems with image/png; mode=24bit!
$url = str_replace(";", "%3B", $url);
if (func_num_args() == 2) {
$auth = func_get_arg(1);
}
//auth should be an array of ['username', 'realm', 'password', 'auth_type'] - or false - problem would be, that these are stored without hashing them!
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
//for images
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//dont store and load cookies from previous sessions
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
//allow https connections and handle certificates quite simply ;-)
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeOut);
//$e = new mb_notice("connector: test1:");
//get hostname/ip out of url
//$host = parse_url($url,PHP_URL_HOST);
$arURL = parse_url($url);
$host = $arURL["host"];
$port = $arURL["port"];
if ($port == '') {
$port = 80;
}
$path = $arURL["path"];
// fill array (HOSTs not for Proxy)
$e = new mb_notice("class_connector.php: NOT_PROXY_HOSTS:" . NOT_PROXY_HOSTS);
$NOT_PROXY_HOSTS_array = explode(",", NOT_PROXY_HOSTS);
//check if http_proxy is set as env, if yes, unset it for the curl action here, it will be reset somewhere below - normally not needed, cause it will be only available when at execution time of the script http://php.net/manual/en/function.putenv.php
if (getenv('http_proxy')) {
$e = new mb_notice("class_connector.php: current http_proxy: " . getenv('http_proxy') . " will be unset by putenv('http_proxy')");
$tmpHttpProxy = getenv('http_proxy');
putenv("http_proxy");
//this should unset the variable???
} else {
$e = new mb_notice("class_connector.php: http_proxy is not set as env variable!");
$tmpHttpProxy = getenv('http_proxy');
}
//$tmpHttpProxy = getenv('http_proxy')?getenv('http_proxy') : "";
//putenv("http_proxy");
//check if proxy is set and server not in NOT_PROXY_HOSTS
if (CONNECTION_PROXY != "" and in_array($host, $NOT_PROXY_HOSTS_array) != true) {
curl_setopt($ch, CURLOPT_PROXY, CONNECTION_PROXY . ":" . CONNECTION_PORT);
$e = new mb_notice("class_connector.php: Proxy will be used!");
if (CONNECTION_PASSWORD != "") {
curl_setopt($ch, CURLOPT_PROXYUSERPWD, CONNECTION_USER . ':' . CONNECTION_PASSWORD);
}
} else {
$e = new mb_notice("class_connector.php: Proxy will not be used!");
}
//TODO maybe allow basic authentication for client, but this will store the passwords in plain text
//TODO: store the passwords as digest hash. Therefor we have to handle the realm which is defined in the 401 header and return it back to the scripts like mod_loadwms.php to store the digest into the database - problem: curl cannot handle digest connection without clear username and password - we have to send our own headers
if (isset($auth) && $auth != false) {
curl_setopt($ch, CURLOPT_USERPWD, $auth['username'] . ':' . $auth['password']);
if ($auth['auth_type'] == 'digest') {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
}
if ($auth['auth_type'] == 'basic') {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
}
}
//if httpType is POST, set CURLOPT_POST and CURLOPT_POSTFIELDS
//and set a usefull http header
if (strtoupper($this->httpType) == 'POST') {
$headers = array("POST " . $path . " HTTP/1.1", "Content-type: " . $this->httpContentType . "; charset=" . CHARSET, "Cache-Control: no-cache", "Pragma: no-cache", "Content-length: " . strlen($this->httpPostData));
$e = new mb_notice("connector: CURL POST: " . $this->httpPostData);
$e = new mb_notice("connector: CURL POST length: " . strlen($this->httpPostData));
if ($this->curlSendCustomHeaders) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
if ($this->httpPostFieldsNumber != 1) {
curl_setopt($ch, CURLOPT_POST, $this->httpPostFieldsNumber);
} else {
curl_setopt($ch, CURLOPT_POST, 1);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->httpPostData);
}
$useragent = CONNECTION_USERAGENT;
//Build own headers for GET Requests - maybe needful?
if (strtoupper($this->httpType) == 'GET') {
$headers = array("GET " . $path . " HTTP/1.1", "User-Agent: " . $_SERVER['HTTP_USER_AGENT'], "Host: " . $host, "Accept: */*", "Proxy-Connection: Keep-Alive");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
#curl_setopt($ch, CURLOPT_HEADER, true);
$e = new mb_notice("class_connector.php: CURL connect to: " . $url);
//curl_setopt ($ch,CURLOPT_USERAGENT,$useragent);
curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_FORBID_REUSE, false);
//curl_setopt ($ch,HTTPPROXYTUNNEL, 1);
//curl_setopt ($ch,CURLOPT_AUTOREFERER, 1);
//curl_setopt ($ch,CURLOPT_VERBOSE, true);
//$handle = fopen('/tmp/phpcurl_error.tmp', 'a'); //use this for debugging purposes
//curl_setopt ($ch,CURLOPT_STDERR, $handle);
$file = curl_exec($ch);
//.........这里部分代码省略.........
示例13: while
//Object oriented style
while ($row = $result->fetch_row()) {
// printf ("%s (%s)\n", $row[0], $row[1]);
//echo "<tr><th>{$row[0]}</th>";
if ($Swap == "N") {
$strrepFN = Str_replace("_", " ", $row[1]) . " ";
//echo $row[1]; ///Cust FName
//echo " ";
$strrepLN = Str_replace("_", " ", $row[2]);
//echo $row[2]; //CustLName
} else {
//swap around firstname with lastname:
$strrepFN = Str_replace("_", " ", $row[2]) . " ";
//echo $row[2]; ///Cust FName
//echo " ";
$strrepLN = Str_replace("_", " ", $row[1]);
//echo $row[1]; //CustLName
}
$Email = $row[5];
// Cust Email FROM CUSTOMER TABLE!!!
$E = $row[5];
$Abbr = $row[13];
$rowNULL = $row[0];
}
// free result set
$result->close();
}
$TAmt = $rowI['TotAmt'];
//$TAmt = number_format ($TAmt, 2, ".", "");
$strD1 = strtr($rowI['D1'], array('_' => ' '));
$strQ1 = $rowI['Q1'];
示例14: getMeteoAlarm
public function getMeteoAlarm($area = '')
{
global $SITE, $warnScriptName, $noaaEvents, $noaaEventIcons;
$this->charset = $SITE['charset'];
#
# check environment setting
# if ( isset ($SITE['warnOffset']) && ($SITE['warnOffset'] > -3601) && ($SITE['warnOffset'] < 7200) ) { $this->timeOffset = $SITE['warnOffset']; }
if (isset($SITE['timeFormat'])) {
$this->timeFormat = $SITE['timeFormat'];
}
if (isset($SITE['timeOnlyFormat'])) {
$this->timeOnlyFormat = $SITE['timeOnlyFormat'];
}
#
$this->area = trim($area);
// user input by call of this function
$this->langAlarm = 'en_US';
$this->cachePath = $SITE['cacheDir'];
#-------------------------------------------------------------------------------
# check if data (for this location) is in cache
#-------------------------------------------------------------------------------
$from = array('.', 'php');
$string = $warnScriptName . '_' . $this->area . '_' . $this->langAlarm;
$string = str_replace($from, '', $this->cachePath . $string);
$this->cache_file = $string . '.txt';
$returnArray = $this->loadFromCache();
// load from cache returns data only when its data is valid
if (!empty($returnArray)) {
// if data is in cache and valid return data to calling program
return $returnArray;
}
// eo return to calling program
#-------------------------------------------------------------------------------
# combine user constants and input (1)location (2)units for temp etc to required url
#-------------------------------------------------------------------------------
$this->urlPart[1] = $this->area;
$this->fullUrl = '';
for ($i = 0; $i < count($this->urlPart); $i++) {
$this->fullUrl .= $this->urlPart[$i];
}
# echo $this->fullUrl; exit;
#----------------------------------------------------------------------------------------------
if (!$this->makeRequest()) {
// no good data loaded
return false;
}
# // we have to check if there are warnings
$this->rawData = Str_replace('cap:', 'cap_', $this->rawData);
$xml = new SimpleXMLElement($this->rawData);
$color = '';
$strNoWarn = 'here are no active';
$pos = strpos($this->rawData, $strNoWarn);
if ($pos != false) {
// no warnings this time
$returnArray['general']['msg'] = 'no warnings';
$returnArray['general']['title'] = (string) $xml->entry->title;
$this->writeToCache($returnArray);
$this->rawData = '';
return $returnArray;
}
# // we have to process every warning
$returnArray['general']['id'] = (string) $xml->id;
$returnArray['general']['title'] = (string) $xml->title;
$returnArray['general']['link'] = (string) $xml->link['href'];
$endWarn = count($xml->entry);
$returnArray['general']['msg'] = (string) $endWarn;
for ($cntWarn = 0; $cntWarn < $endWarn; $cntWarn++) {
$data = $xml->entry[$cntWarn];
# $returnArray[$cntWarn]['color'] = (string) $data->cap_effective;
$unixFrom = strtotime((string) $data->cap_effective);
$returnArray['warn'][$cntWarn]['from'] = date($SITE['timeFormat'], $unixFrom);
$unixTo = strtotime((string) $data->cap_expires);
$From = date('Ymd', $unixFrom);
$To = date('Ymd', $unixTo);
if ($From != $To) {
$returnArray['warn'][$cntWarn]['until'] = date($SITE['timeFormat'], $unixTo);
} else {
$returnArray['warn'][$cntWarn]['until'] = date($SITE['timeOnlyFormat'], $unixTo);
}
$event = (string) $data->cap_event;
$returnArray['warn'][$cntWarn]['event'] = $event;
$type = $noaaEvents[$event]['types'];
$returnArray['warn'][$cntWarn]['types'] = $type;
$returnArray['warn'][$cntWarn]['severity'] = (string) $data->cap_severity;
$returnArray['warn'][$cntWarn]['areaDesc'] = (string) $data->cap_areaDesc;
$returnArray['warn'][$cntWarn]['img'] = $noaaEventIcons[$type];
$returnArray['warn'][$cntWarn]['summary'] = (string) $data->summary;
$returnArray['warn'][$cntWarn]['link'] = (string) $data->link['href'];
$returnArray['warn'][$cntWarn]['urgency'] = (string) $data->cap_urgency;
}
// eo for all warnings
# print_r ($xml); print_r ($returnArray); exit;
$this->writeToCache($returnArray);
$this->rawData = '';
return $returnArray;
}