Skip to content

Instantly share code, notes, and snippets.

<?php
class Parser{
public $responseArr = [];
function __construct($url)
{
$this->url = $url;
}
/**************************************
Таблица в массив php
**************************************/
<?php
$re = '/<tr>(.+?)<\/tr>/ms';
$re_td = '/<td[^>].*?>(.*?)<\/td>/ms';
$str = '<table>
<tbody>
<tr>
https://javascript.ru/php
http://locutus.io/php/
/***********************
range
https://dev.to/ycmjason/how-to-create-range-in-javascript-539i
***********************/
function range(start, end) {
var ans = [];
for (let i = start; i <= end; i++) {
#!/bin/bash
usage() { echo "Manual: $0 [-c <string> -f <path>]" 1>&2; exit 1; }
while getopts ":c:f:" o; do
case "${o}" in
c)
c=${OPTARG}
;;
f)
/************
скрыть/показать пароль
без всяких крутых вещей. Главный принцип
**************/
<input type="password" id="password">
<input type="checkbox" onchange="document.getElementById('password').type = this.checked ? 'text' : 'password'"> Show password
// и второй вариант. На Jquery пока не переделал
$('.show-key').click(function() {
document.getElementById('api_key').type = "text";
/************ выделения пункта меню при активном якоре **************/
//http://jsfiddle.net/bonilka/p7sgwg4L/
<script>
jQuery(window).scroll(function(){
var $sections = $('div');
$sections.each(function(i,el){
var top = $(el).offset().top-100;
var bottom = top +$(el).height();
var scroll = $(window).scrollTop();
var id = $(el).attr('id');
//https://impuls-web.ru/css-xaki-kak-zadat-css-stili-dlya-raznyx-brauzerov/
/* стили для мозилы */
_:-moz-any-link, :root .new_wid{width: 70% !important;}
/* стили для хрома */
_:-webkit-any-link, :root .new_wid{width: 70% !important;}
/**** стили для разных размеров окна браузера ***/
@media screen and (min-width: 1628px){
.ting-product__text{
<?php
/********* универсальное решение ****************/
function sendRequest($url, array $params = [], $post = false){
$curl = curl_init();
$headers = array(
'Content-Type: application/json-patch+json',
'accept: application/json',
);
if ($post == true) {
<?php
/**************
класс чтения и записе csv файла
***************/
/**********************
Иногда при просмотре csv файла в эксель, выходит странная кодровка. Дело не в самой кодировки файла, а в отсутствие одной опции.
fprintf ( $ fp , chr ( 0xEF ). chr ( 0xBB ). chr ( 0xBF ));
В общем виде выглядит это так
$fp = fopen("путь", 'r+');
<?php
/****************** удаляем из массива ******************/
//массив из которого нужно удалить
$letters = array('(', ')', '[', ']', '{', '}','h', 'r','ff');
//массив данных, которые не трогаем
$no_delete = array('(', ')', '[', ']', '{', '}');
foreach($letters_new as $key => $char){