$regex = "([а-яА-Яa-zA-Z0-9]*|[.,-_!?;:'\(\)\"]*)";
$string = "МАЗ 5551 - популярный белорусский грузовик-самосвал, с самосвальным оборудованием. Он выпускается на минском автомобильном заводе!";
preg_match_all("/$regex/", $string, $matches);
$matches = $matches[1];
array_walk($matches, function ($value, $key) use (&$matches) {
if(strlen($matches[$key]) < 1) {
unset($matches[$key]);
}
});
echo '<pre>';
print_r($matches);
// src/ControllerIndexController::data
public function data()
{
$data = $this->getDoctrine()->getRepository(Data::class)->findOneBy([]);
return $this->render('data.html.twig', ['data' => $data]);
}
<!-- data.html.twig -->
{{ data }}
<!-- base.html.twig -->
{% block footer %}
<footer>
{{ render(controller('App\\Controller\\IndexController::data')) }}
</footer>
{% endblock %}
$stdObjects = json_decode(stripslashes($json));
foreach($stdObjects->events as $e) {
$event = new Event();
$event->title = $e->title;
$event->date = $e->date;
// $this->getDoctrine()->persist($event);
}
// $this->getDoctrine()->flush();
// class Event {
// public $title;
// public $date;
// }
$str1 = '(56.61926920000001, 84.88168339999993):8';
$str2 = '56.61926920000001, 84.12';
$str3 = '56.61926920000001, 84';
preg_match_all('/([\d]*[.][\d]*)/', $str1, $matches);
print_r($matches[1]);
// [0] => 56.61926920000001
// [1] => 84.88168339999993
preg_match_all('/([\d]*[.][\d]*)/', $str2, $matches);
print_r($matches[1]);
// [0] => 56.61926920000001
// [1] => 84.12
preg_match_all('/([\d]*[.][\d]*)/', $str3, $matches);
print_r($matches[1]);
// [0] => 56.61926920000001
class DocumentUserRepository extends EntityRepository
{
public function findByUserAccountDocument(array $users, $account, $document)
{
return $this->createQueryBuilder('a')
->andWhere('a.user IN (:users)')->setParameter('users', $users)
->andWhere('a.account = :account')->setParameter('account', $account)
->andWhere('a.document = :document')->setParameter('document', $document)
->getQuery()->getResult();
}
}
$url = 'https://vk.com/public33333333';
$regexp = 'https?:\/\/([^\s]*)';
preg_match("/$regexp/", $url, $matches);
print_r($matches[1]);
<select id="sel" onchange="change()">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">..</option>
</select>
<div id="message"></div>
<script>
function change() {
document.getElementById("message").innerHTML = document.getElementById("sel").value;
}
</script>
class Book {
/**
* @ORM\ManyToOne(targetEntity="Page", cascade={"remove"})
*/
protected $pages;
abstract class AbstractClass
{
protected function request($body)
{
return Document::TEST_VALUE;
}
}
class Document extends AbstractClass
{
const TEST_VALUE = 403;
public function handle($params)
{
$requestBody = 'body';
return $this->request($requestBody);
}
}
class DocumentTest
{
public function testRequest()
{
$doc = new Document();
$result = $this->invokeMethod($doc, 'request', [1]);
self::assertEquals(Document::TEST_VALUE, $result);
}
private function invokeMethod(&$object, $methodName, array $parameters = array())
{
$reflection = new \ReflectionClass(get_class($object));
$method = $reflection->getMethod($methodName);
$method->setAccessible(true);
return $method->invokeArgs($object, $parameters);
}
}
use FOS\UserBundle\Model\User as FosUser;
class User extends FosUser
{
}