How to include other arrays in an array in php?

WBOY
Release: 2016-08-04 09:20:49
Original
1786 people have browsed it

<code>        $name1=$_POST['name'];
        $hobbyS1=array();
        $hobbyS1=$_POST['hobbyS'];
        $sre1=$_POST['sre'];

        $fields = array($name1,$sre1);
        echo implode($fields);</code>
Copy after login
Copy after login

As shown in the above code, it displays normally.
I want to put the array hobbyS1 into $fields. How can I achieve this?
This is what I do
$fields = array($name1,$sre1,$hobbyS1);
No,
how should I put it? Thank you

Reply content:

<code>        $name1=$_POST['name'];
        $hobbyS1=array();
        $hobbyS1=$_POST['hobbyS'];
        $sre1=$_POST['sre'];

        $fields = array($name1,$sre1);
        echo implode($fields);</code>
Copy after login
Copy after login

As shown in the above code, it displays normally.
I want to put the array hobbyS1 into $fields. How can I achieve this?
This is what I do
$fields = array($name1,$sre1,$hobbyS1);
No,
how should I put it? Thank you

How to include other arrays in an array in php?

<code>var_dump($_POST)   看下有没有值,正常是可以的
</code>
Copy after login

$fileds = array($name1, $sre1); can be used after

<code>array_push($fileds, $hobbyS1); 
OR
$fields[] = $hobbyS1
</code>
Copy after login

How to include other arrays in an array in php?

After execution:

<code>$fields = array($name,$sre1);</code>
Copy after login

Use:

<code>$fields[] = $hobbyS1;
</code>
Copy after login

I tried it and it works

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template