本文整理汇总了PHP中chop函数的典型用法代码示例。如果您正苦于以下问题:PHP chop函数的具体用法?PHP chop怎么用?PHP chop使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
*
* @param Horde_Vcs_Base $rep A repository object.
* @param string $dn Path to the directory.
* @param array $opts Any additional options:
*
* @throws Horde_Vcs_Exception
*/
public function __construct(Horde_Vcs_Base $rep, $dn, $opts = array())
{
parent::__construct($rep, $dn, $opts);
$cmd = $rep->getCommand() . ' ls ' . escapeshellarg($rep->sourceroot . $this->_dirName);
$dir = proc_open($cmd, array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
if (!$dir) {
throw new Horde_Vcs_Exception('Failed to execute svn ls: ' . $cmd);
}
if ($error = stream_get_contents($pipes[2])) {
proc_close($dir);
throw new Horde_Vcs_Exception($error);
}
/* Create two arrays - one of all the files, and the other of all the
* dirs. */
$errors = array();
while (!feof($pipes[1])) {
$line = chop(fgets($pipes[1], 1024));
if (!strlen($line)) {
continue;
}
if (substr($line, 0, 4) == 'svn:') {
$errors[] = $line;
} elseif (substr($line, -1) == '/') {
$this->_dirs[] = substr($line, 0, -1);
} else {
$this->_files[] = $rep->getFile($this->_dirName . '/' . $line);
}
}
proc_close($dir);
}
示例2: isRequired
/**
* @ignore
*/
public static function isRequired($uValue)
{
if (strlen(chop($uValue)) === 0) {
return false;
}
return true;
}
示例3: before
function before($route)
{
$lang_mapping = array('fr' => 'fr_FR');
if (!isset($_SESSION['locale'])) {
$locale = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$_SESSION['locale'] = strtolower(substr(chop($locale[0]), 0, 2));
}
$lang = $_SESSION['locale'];
// Convert simple language code into full language code
if (array_key_exists($lang, $lang_mapping)) {
$lang = $lang_mapping[$lang];
}
$lang = "{$lang}.utf8";
$textdomain = "localization";
putenv("LANGUAGE={$lang}");
putenv("LANG={$lang}");
putenv("LC_ALL={$lang}");
putenv("LC_MESSAGES={$lang}");
setlocale(LC_ALL, $lang);
setlocale(LC_CTYPE, $lang);
$locales_dir = dirname(__FILE__) . '/i18n';
bindtextdomain($textdomain, $locales_dir);
bind_textdomain_codeset($textdomain, 'UTF-8');
textdomain($textdomain);
set('locale', $lang);
}
示例4: testSerialization
public function testSerialization()
{
$msg = new XPSoapMessage();
$msg->createCall('Test', 'testSerialization');
$this->assertEquals('Test', $msg->action);
$this->assertEquals('testSerialization', $msg->method);
$this->assertEquals('SOAP-ENV:Envelope', $msg->root()->getName());
$this->assertNotEmpty($msg->root()->getAttributes());
$msg->setData(array('int' => 1, 'float' => 6.1, 'string' => 'Binford', 'string2' => '"<&>"', 'bool' => true, 'date' => \util\Date::fromString('1977-12-14 11:55AM Europe/Berlin'), 'null' => null, 'array' => array(2, 3), 'hash' => array('class' => 'Test', 'method' => 'testSerialization')));
// Let's be somewhat forgiving on whitespace
$src = trim(chop($msg->getSource(0)));
$this->assertEquals('<SOAP-ENV:Envelope', substr($src, 0, 18));
$this->assertEquals('</SOAP-ENV:Envelope>', substr($src, -20));
$this->assertContains($src, '<int xsi:type="xsd:int">1</int>', 'integer');
$this->assertContains($src, '<float xsi:type="xsd:float">6.1</float>', 'float');
$this->assertContains($src, '<string xsi:type="xsd:string">Binford</string>', 'string');
$this->assertContains($src, '<string2 xsi:type="xsd:string">"<&>"</string2>', 'escaping');
$this->assertContains($src, '<bool xsi:type="xsd:boolean">true</bool>', 'bool');
$this->assertContains($src, '<date xsi:type="xsd:dateTime">1977-12-14T11:55:00+01:00</date>', 'date');
$this->assertContains($src, '<null xsi:nil="true"/>', 'null');
$this->assertContains($src, '<array xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[2]">', 'array');
$this->assertContains($src, '<item xsi:type="xsd:int">2</item>', 'array.inner');
$this->assertContains($src, '<item xsi:type="xsd:int">3</item>', 'array.inner');
$this->assertContains($src, '<hash xsi:type="xsd:struct">', 'hash');
$this->assertContains($src, '<class xsi:type="xsd:string">Test</class>', 'hash.inner');
$this->assertContains($src, '<method xsi:type="xsd:string">testSerialization</method>', 'hash.inner');
return $src;
}
示例5: walk
function walk($item1)
{
$item1 = str_replace(' ', '|', $item1);
$item1 = str_replace('"', '', $item1);
$item1 = str_replace("\n", '', $item1);
$item1 = str_replace("\r", '', $item1);
//$item1 = str_replace("",'',$item1);
$item1 = str_replace('"', '\\"', $item1);
$item1 = str_replace("'", '\\"', $item1);
// echo $item1."<br>";
$item1 = chop($item1);
echo $item1 . "<br>";
$items = explode("|", $item1);
$products_id = $items[0];
$products_model = $items[1];
$products_name = $items[2];
$products_tax_class_id = $items[3];
$products_status = $items[4];
$products_price = $items[5];
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$tax_ratestable = $oostable['tax_rates'];
$query = "SELECT tax_rate FROM {$tax_ratestable} WHERE tax_class_id = '" . intval($products_tax_class_id) . "'";
$tax = $dbconn->GetOne($query);
$price = $products_price / ($tax + 100) * 100;
$productstable = $oostable['products'];
$dbconn->Execute("UPDATE {$productstable} set products_price = '" . $price . "', products_status = '" . intval($products_status) . "' where products_id = '" . intval($products_id) . "'");
}
示例6: sanitizeClassName
/**
* @param $className
* @return bool
*/
public function sanitizeClassName($className)
{
if (trim(substr($className, -1)) == 's') {
$className = chop($className, 's');
}
return ucfirst($className);
}
示例7: getMemberForm
function getMemberForm($str, $type, $flag)
{
global $DB_CONNECT, $MemberType_Array;
if (!$MemberType_Array) {
$Group_Data = db_query("SELECT * FROM kimsmall7_members_group ORDER BY MG_TYPE", $DB_CONNECT);
while ($MEMBER_GROUP = db_fetch_array($Group_Data)) {
$MemberType_Array[] = $MEMBER_GROUP[MG_NAME];
}
}
$g_num = sizeof($MemberType_Array);
if ($str) {
$ret_code = "<option value=''>{$str}</option>\n";
}
for ($i = 0; $i < $g_num && chop($MemberType_Array[$i]); $i++) {
if ($type != $i + 1) {
$ret_code .= "<option value='" . ($i + 1) . "'>[" . ($i + 1) . "]{$MemberType_Array[$i]}</option>\n";
} else {
$ret_code .= "<option value='" . ($i + 1) . "' selected>[" . ($i + 1) . "]{$MemberType_Array[$i]}</option>\n";
}
}
if ($flag) {
$g_num++;
$ret_code = "<option value='0' style='background:#6CCFF8;'>[0]비회원</option>" . $ret_code;
$ret_code .= $type == $g_num ? "<option value='" . $g_num . "' selected style='background:gold;'>[" . $g_num . "]관리자</option>" : "<option value='" . $g_num . "' style='background:gold;'>[" . $g_num . "]관리자</option>";
return $ret_code;
} else {
return $ret_code;
}
}
示例8: doPost
function doPost($uri, $postdata, $host)
{
$da = fsockopen($host, 80, $errno, $errstr);
if (!$da) {
echo "{$errstr} ({$errno})<br/>\n";
echo $da;
} else {
$salida = "POST {$uri} HTTP/1.1\r\n";
$salida .= "Host: {$host}\r\n";
$salida .= "User-Agent: PHP Script\r\n";
$salida .= "Content-Type: application/x-www-form-urlencoded\r\n";
$salida .= "Content-Length: " . strlen($postdata) . "\r\n";
$salida .= "Connection: close\r\n\r\n";
$salida .= $postdata;
fwrite($da, $salida);
while (!feof($da)) {
$response .= fgets($da, 128);
}
$response = split("\r\n\r\n", $response);
$header = $response[0];
$responsecontent = $response[1];
if (!(strpos($header, "Transfer-Encoding: chunked") === false)) {
$aux = split("\r\n", $responsecontent);
for ($i = 0; $i < count($aux); $i++) {
if ($i == 0 || $i % 2 == 0) {
$aux[$i] = "";
}
}
$responsecontent = implode("", $aux);
}
//if
return chop($responsecontent);
}
//else
}
示例9: get_layers
function get_layers($tiles, $zoom)
{
global $attribution, $attrib_plain;
$needed = explode('|', $tiles);
$result = array();
$attribution = 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a>';
$file = @fopen('tiles.txt', 'r');
if ($file) {
while (($line = fgets($file)) !== false) {
$layer = explode(',', chop($line));
if (in_array($layer[0], $needed) && (count($result) ? $layer[1] : !$layer[1]) && $layer[2] <= $zoom && $layer[3] >= $zoom) {
$result[] = $layer[4];
if (strlen($layer[5])) {
$attribution .= ', ' . $layer[5];
}
}
if (count($result) >= 4) {
break;
}
}
fclose($file);
}
if (!count($result)) {
$result[] = 'http://tile.openstreetmap.org/!z/!x/!y.png';
}
$attrib_plain = str_replace('©', '(c)', preg_replace('/<[^>]+>/', '', $attribution));
return $result;
}
示例10: git
protected function git($Provider)
{
if ($Provider->getHook() != 'pre-rebase') {
return true;
}
$argv = $_SERVER['argv'];
$rebaseBranch = $argv[0];
if (!empty($argv[1])) {
$topicBranch = 'refs/heads/' . $argv[1];
} else {
$topicBranch = chop($Provider->execute('git symbolic-ref HEAD'));
}
$shas = explode("\n", $Provider->execute("git rev-list {$rebaseBranch}..{$topicBranch}"));
$refs = array_map('trim', explode("\n", $Provider->execute("git branch -r")));
foreach ($shas as $sha) {
foreach ($refs as $ref) {
$pushed = chop($Provider->execute("git rev-list ^{$sha}^@ refs/remotes/{$ref}")) == $sha;
if ($pushed) {
$this->output("Commit {$sha} has already been pushed to {$ref}", true, true);
return;
}
}
}
$message = "Rebase of {$rebaseBranch} does not overwrite any of {$topicBranch} remote commits";
$this->output($message);
return true;
}
示例11: read_wiki
function read_wiki() {
global $wiki_stylesheet;
global $columns;
$data=array();
$f=fopen($wiki_stylesheet, "r");
unset($this_part);
while($r=fgets($f)) {
$r=chop($r);
if(ereg("==([^=]+)==", $r, $m)) {
$mode=0;
$part=trim($m[1]);
}
if(substr($r, 0, 1)=="|") {
$this_row=get_row($r, $f);
if($this_row&&($columns[$part])) {
$src=array();
foreach($this_row as $i=>$r2) {
$src[$columns[$part][$i]]=trim($r2);
}
$data[$part][]=$src;
}
}
}
fclose($f);
return $data;
}
示例12: CreatLinks
function CreatLinks()
{
global $TMP_FOLDER, $DOCUMENT_ROOT, $SUB_FOLDER;
$File = "symlinks.txt";
$COPY_FOLDER = $DOCUMENT_ROOT . $SUB_FOLDER;
# сколько ссылок создно, сколько всего ссылок
$result = array("links" => 0, "total" => 0);
$fp = fopen($TMP_FOLDER . $File, "r");
while (!feof($fp)) {
$string = chop(fgets($fp, 4096));
if (strlen($string) == 0) {
break;
}
$From = strtok($string, " ");
$To = strtok(" ");
$directory = dirname($To);
$tmpDirectory = $COPY_FOLDER;
$tok = strtok($directory, "/");
while ($tok) {
$tmpDirectory .= "/" . $tok;
@mkdir($tmpDirectory, 0775);
$tok = strtok("/");
}
# Для Windows-платформ эта функция не реализована.
$linked = @symlink($COPY_FOLDER . "/" . $From, $COPY_FOLDER . "/" . $To);
if ($linked) {
$result["links"]++;
}
$result["total"]++;
}
fclose($fp);
return $result;
}
示例13: ansispan
function ansispan($string)
{
if (preg_match("/(#[0-f][0-f][0-f][0-f][0-f][0-f]|[+][a-z0-9]+)(\\/(#[0-f][0-f][0-f][0-f][0-f][0-f]|[+][a-z0-9]+))?/", $string[1])) {
$temp = preg_replace("/((#[0-f][0-f][0-f][0-f][0-f][0-f])|[+]([a-z0-9]+))/", "\\2\\3", $string[1]);
return "<span style=\"color:{$temp}\">";
}
$fg = 'n';
$bg = 'n';
$bold = 0;
$invert = 0;
$result = "";
$result_array = str_split($string[1]);
foreach ($result_array as $char) {
if (preg_match("/[A-Z]/", $char)) {
$bg = strtolower($char);
} elseif ($char == 'i') {
$invert = 1;
} elseif ($char == 'h') {
$bold = 1;
} elseif ($char == 'f') {
$result .= "flash ";
} elseif ($char == 'u') {
$result .= "underline ";
} else {
$fg = $char;
}
}
$fg = ($invert ? "bg_" : "fg_") . $fg;
$bg = ($invert ? "fg_" : "bg_") . $bg;
$fg = $bold ? "bold_" . $fg : $fg;
$result = chop($result);
return "{$inverta}<span class=\"{$result} {$fg} {$bg} ++ {$string['1']}\">";
}
示例14: updatebiz_categoriesData
function updatebiz_categoriesData($setArray, $conditionArray)
{
$set = '';
$condition = '';
/* Setting up setArray */
if ($setArray != '1') {
while (list($key, $val) = each($setArray)) {
$set .= $key . "='" . $val . "',";
}
$set = chop($set, ",");
} else {
$set = $setArray;
}
/* Setting up conditionArray */
if ($conditionArray != '1') {
while (list($key, $val) = each($conditionArray)) {
$condition .= $key . "='" . $val . "',";
}
$condition = chop($condition, ",");
} else {
$condition = $conditionArray;
}
$updateQuery = "UPDATE biz_categories ";
$updateQuery .= "SET " . $set;
$updateQuery .= "WHERE " . $condition;
$this->logger->info("[func - updatebiz_categoriesData()] Query : " . $updateQuery);
$dbObject = new Database();
$conn = $dbObject->dbinteraction($biz_sname, $biz_dbname, $biz_user, $biz_pwd);
$dbObject->addupdateData($conn, $updateQuery);
$conn->close();
}
示例15: createPods
public function createPods($eventId)
{
$this->t = new Transaction();
$sql = 'UPDATE event SET started = TRUE WHERE id = ' . Q($eventId);
$this->t->execute($sql);
$players = (new Events())->players($eventId);
shuffle($players);
$pods = [];
$podNums = $this->determinePods(count($players));
foreach ($podNums as $podCount) {
$podId = $this->createPod($eventId);
$pod = [];
for ($seat = 1; $seat <= $podCount; $seat++) {
$player = array_pop($players);
$player['seat'] = $seat;
$pod[] = $player;
}
$sql = 'INSERT INTO player_pod (pod_id, player_id, seat) VALUES ';
foreach ($pod as $player) {
$sql .= ' (' . Q($podId) . ', ' . Q($player['player_id']) . ', ' . Q($player['seat']) . '), ';
}
$sql = chop($sql, ', ');
$this->t->execute($sql);
}
$this->t->commit();
}