function getWinCount(team) {
const el = Array
.from(document.querySelectorAll('.table-item__name'))
.find(n => n.textContent === team);
return el ? +el.closest('tr').children[3].textContent : null;
}
const wins = getWinCount('Уфа');
Мой браузер не поддерживает ES-2015
function getWinCount(team) {
var el = null;
[].concat.apply([], document.querySelectorAll('.table-item__name')).forEach(function(n) {
if (!el && n.textContent === team) {
el = n;
}
});
if (!el) {
return null;
}
do {
el = el.parentNode;
} while (el.tagName !== 'TR');
return +el.children[3].textContent;
}
$('.price').text((i, text) => {
const [ price, currency ] = text.split(' ');
return `${(+price).toLocaleString()} ${currency}`;
});
// или
document.querySelectorAll('.price').forEach(n => {
n.textContent = n.textContent.replace(/\d(?=(\d{3})+\D)/g, '$& ');
});
var FeedParser = (function() {
function FeedParser(Feed_Table_StatsParser) {
this.DELIMITER_ROW = "~";
this.DELIMITER_CELL = "¬";
this.DELIMITER_VALUE = "÷";
this.statsParser = Feed_Table_StatsParser
}
FeedParser.prototype.parse = function(feed) {
var statsParser = this.statsParser;
statsParser.startFeed();
var rows = feed.split(this.DELIMITER_ROW);
for (var _i = 0, rows_1 = rows; _i < rows_1.length; _i++) {
var row = rows_1[_i];
statsParser.startRow();
var cells = row.split(this.DELIMITER_CELL);
for (var _a = 0, cells_1 = cells; _a < cells_1.length; _a++) {
var cell = cells_1[_a];
var keyValue = cell.split(this.DELIMITER_VALUE);
statsParser.parse(keyValue[0], keyValue[1])
}
statsParser.endRow()
}
statsParser.endFeed();
return statsParser.getParsedModel()
};
return FeedParser
}());
$url = 'https://mysite.com/aaa/bbb/123_multi.jpg';
$searchStr = '_multi';
$parseUrl = parse_url($url);
$pathInfo = pathinfo($parseUrl['path']);
$a = $parseUrl['scheme'] . '://' . $parseUrl['host'] . $pathInfo['dirname'];
$b = $pathInfo['basename'];
$c = (int)(substr($pathInfo['filename'], -strlen($searchStr)) === $searchStr);
import subprocess
args = ["ping.exe", "www.yahoo.com"]
process = subprocess.Popen(args, stdout=subprocess.PIPE)
data = process.communicate()
print(data)
На основе этого значения надо менять результат внутри callback-функции передаваемой вторым параметром usort()
function array_sort(array &$arr, $key, $sort = 'asc') {
$sort = $sort === 'asc' ? 1 : -1;
usort($arr, function($a, $b) use($sort, $key) {
$a = $a[$key];
$b = $b[$key];
return $sort * ($a === $b ? 0 : $a > $b ? 1 : -1);
});
}