简体   繁体   中英

How can I remove the underlines from my post array elements?

I can't seem to find a simple solution. I'm trying to loop through a $_POST array like this:

foreach($_POST as $value => $key)
{
    echo $value;        
}

The values that I get back are all chained together with underline character like this:

Element_one_Element_two_Element_Three_Element_Four_submit

How can I get the array to simply display each elements without the underline and the appropriate break like this:

Element one
Element two
Element three
Element four

Because I'm creating and sending the contents of the post array dynamically to the database I don't to use hard code like $_POST["someArrayElementName'];

Thanks for any help!

This should work for you:

(Here I just simply use str_replace() to change all underlines to spaces and at the end I append a new line tag)

echo str_replace("_", " ", $value) . "<br />";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM