php - print_r not allowing me to escape []
Get the solution ↓↓↓How can I escape the []? If I execute the following code, it just throws me an error
<?php
$url = 'http://www.example.com/page/?type=software&sortby=title&sortdirection=asc&Name[]=make%3A%20microsoft';
$url_components = parse_url($url);
parse_str($url_components['query'], $params);
echo ' The '.print_r($params['Name[]']);
?>
Answer
Solution:
The name is justName
and you should useimplode
to join the pieces back together.
echo ' The '. implode($params['Name']);
This assumes your parameter is alwaysName[]
.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: installation failed, reverting ./composer.json and ./composer.lock to their original content
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.