$postid = get_the_ID(); echo $postid; $newposturl = get_post_meta( $postid, ‘permalink’ ); $newurl=$newposturl[«0»]; $my_post = array( ‘ID’ => $postid, ‘post_name’ => $newurl ); wp_update_post( $my_post );
Метка: рабочие заметки
PHP парсинг таблицы
Используем библиотеку: http://simplehtmldom.sourceforge.net/ $html = file_get_html(‘http://flow935.com/playlist/flowhis.HTM’); foreach($html->find(‘tr’) as $row) { // Parse table row here } require(‘simple_html_dom.php’); $table = array(); $html = file_get_html(‘http://flow935.com/playlist/flowhis.HTM’); foreach($html->find(‘tr’) as $row) { $time = $row->find(‘td’,0)->plaintext; $artist = $row->find(‘td’,1)->plaintext; $title = $row->find(‘td’,2)->plaintext; $table[$artist][$title] = true; } print_r($table);
Полезные однострочники BASH
Посчитать количество айпишников в логах apache или nginx: cat access.log |awk ‘{print $1}’ |sort |uniq -c |sort -n|tail Здесь есть еще: http://www.bashoneliners.com/
Изменить таймзону на Debian
Как изменить временную зону timezone на debian а вот так: dpkg-reconfigure tzdata
regex тестирование онлайн
Очень полезный сервис для тестирования regex выражений онлайн, есть примеры всякие: http://gskinner.com/RegExr/