PHPize Online / SQLize Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE `categories` ( `id` int(12) NOT NULL AUTO_INCREMENT, `name` varchar(150) NOT NULL, `description` text NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; INSERT INTO `categories` (`id`, `name`, `description`) VALUES (9, 'php', 'Язык программирования'); CREATE TABLE `posts` ( `id` int(12) NOT NULL AUTO_INCREMENT, `id_user` int(12) NOT NULL, `title` varchar(255) NOT NULL, `content` text NOT NULL, `img` varchar(255) NOT NULL, `id_category` varchar(255) NOT NULL, `status` char(50) NOT NULL, `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; INSERT INTO `posts` (`id`, `id_user`, `title`, `content`, `img`, `id_category`, `status`, `createdAt`) VALUES (1, 51, 'Новый пост', 'post', '', '9', 'P', '2022-07-09 04:18:31'); CREATE TABLE `users` ( `id` int(12) NOT NULL AUTO_INCREMENT, `admin` tinyint(1) DEFAULT NULL, `username` varchar(40) NOT NULL, `email` varchar(40) NOT NULL, `password` varchar(40) NOT NULL, `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `name` char(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `email` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; INSERT INTO `users` (`id`, `admin`, `username`, `email`, `password`, `createdAt`, `name`) VALUES (51, 1, 'Rasul', 'mr.sylaev@mail.ru', '444', '2022-07-05 21:24:09', 'RAS');
Copy
Copy Format Clear
<?php function f(string $s) { $chars = ["E", "A", "R"]; $arr = explode(' ', $s); $arr = array_reduce( $arr, function($acc, $el) use ($chars) { $count = 0; $el = strtolower($el); foreach($chars AS $ch) { $count += substr_count($el, strtolower($ch)); } if ($count>0) $acc[$el] = $count; return $acc; }, [] ); arsort($arr); return $arr; } print_r(f("Loreme ipsum dolor sit amet bcd"));
Show:  
Copy