I need to parse the following string:
$str = 'http://test.al/admin/?plugin=pages&act=delete&file=test-page';
It's dynamic and could contain more &-symbols.
I want to get everything but the part starting from "&..." so the result should be:
http://test.al/admin/?plugin=pages
Use strtok()
:
<?php
$str = 'http://test.al/admin/?plugin=pages&act=delete&file=test-page';
$result = strtok($str, '&');
var_dump($result); // outputs "http://test.al/admin/?plugin=pages"