PHP How do I read the form variables with empty square brackets in their name -


in php file when submit i'm able read following variables quite (see attached picture)

enter image description here

$mobile = $_request['mobile'];   $about = $_request['about'];   $comment = $_request['comment'];  

now question is.. how read "category[]" form value?

just read read normal variables.

$category = $_request['category'];  

unlike other variables return php array. can iterate on variable normal php array.

foreach($category $cat) {     echo $cat; } 

make sure check if request have value you're looking using isset(). otherwise above code might throw undefined indexed error.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -