AbraCadaver m'a donné un lien vers phpsandbox. Le code ci-dessous fonctionne sur http://sandbox.onlinephpfunctions.com/.php, exploser ne fonctionne pas, php preg_replace ne fonctionne pas
Pourquoi cela ne fonctionne pas dans mon ordinateur? J'ai wampstack-5.6.20-0, php version 5.6.20 et vérifiez oce sur Opera, Firefox, Explorer et Chrome.
J'ai une chaîne, que je voudrais partager en morceaux afin de les joindre à une chaîne de colle ou preg_replace la split_substring (AAAA) avec un glue_string (jsonString):
$tmpStr = '<br><div id="10"><p>Displaying 1-5 of 11 results. <br> <span class="disabled">«</span> <span class="disabled">‹</span> Page 1 of 3 pages<a href="?page=2&formData=aaaa" title="Next page">›</a> <a href="?page=3&formData=aaaa" title="Last page">»</a><br>All pages: <a href="?page=1&formData=aaaa">1</a> <a href="?page=2&formData=aaaa">2</a> <a href="?page=3&formData=aaaa">3</a> </p></div><br> ';
$tmpArr = explode("aaaa", $tmpStr);
print_r("<br> 94 EventSearchCOntroller tmpArr =<pre>"); print_r($tmpArr);
Le résultat est :
Array
(
[0] =>
107 PaginatorTrait pagHTML =
Displaying 1-5 of 11 results.
« ‹ Page 1 of 3 pages› »
All pages: 1 2 3
)
$tmpStr2=preg_replace("/aaaa/", "jsonString", $tmpStr);
$tmpStr2=preg_replace("/aaaa/", "jsonString", $tmpStr, 100);
print_r("<br> 97 EventSearchCOntroller tmpStr2 =".$tmpStr2);
//Result is in both cases (using 100 limit, and without a limit):
97 EventSearchCOntroller tmpStr2 =
Si j'imprime les résultats, la chaîne n'est pas coupée. Où est la raison?
Que voulez-vous dire? '$ tmpStr2' est une chaîne et non un tableau. –
Non - http://sandbox.onlinephpfunctions.com/code/82291d872333aa00ae9d885a5b16617f87637832 – AbraCadaver
Lorsque vous voyez la sortie sur un navigateur, le navigateur interprète les balises birraa