Home >Backend Development >PHP Tutorial >The php array is converted into something like this
An array like thisArray ( [0] => a [1] => s [2] => d [3] => f )
is converted into Array ( '0' => ' a','1' => 's', '2' => 'd', '3' => 'f' )
Is it possible? Please give me guidance
In fact, the process is as follows: two strings $atr = 1,2,3,4 $str=a,b,c,f are converted into array array in one-to-one correspondence ('1'=>'a','2' =>'b','3'=>'c','4'=>'f')
And print out array('1'=>'a','2'=>'b','3'=>'c','4'=>'f'), don't know this Is it easy to understand?
Reply content:Array ( [0] => a [1] => s [2] => d [3] => f ) is converted into
Array ( '0' => ' a','1' => 's', '2' => 'd', '3' => 'f' ) Is it possible? Please give me guidance
And print out array('1'=>'a','2'=>'b','3'=>'c','4'=>'f'), don't know this Is it easy to understand?
This of yours cannot be used
If the key of the array can be converted into Int, it will be converted into a number
You can refer to the manual
http://php.net/manual/zh/lang...
<code>Array ( [0] => a [1] => s [2] => d [3] => f ) </code>When such an array display appears, it is generally a friendly display of dump under tp. It's not an array.
<code>$tmp = array( '0' => 'a','1' => 's', '2' => 'd', '3' => 'f' ); var_dump($tmp); </code>
The above code shows:
<code>Array ( [0] => a [1] => s [2] => d [3] => f ) </code>
====================dump source code============================
<code> /** * 浏览器友好的变量输出 * @param mixed $var 变量 * @param boolean $echo 是否输出 默认为true 如果为false 则返回输出字符串 * @param string $label 标签 默认为空 * @return void|string */ public static function dump($var, $echo = true, $label = null) { $label = (null === $label) ? '' : rtrim($label) . ':'; ob_start(); var_dump($var); $output = ob_get_clean(); $output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output); if (IS_CLI) { $output = PHP_EOL . $label . $output . PHP_EOL; } else { if (!extension_loaded('xdebug')) { $output = htmlspecialchars($output, ENT_QUOTES); } $output = '<pre class="brush:php;toolbar:false">' . $label . $output . ''; } if ($echo) { echo ($output); return null; } else { return $output; } }
How did you arrive at this array? ? ! !
Array ( [0] => a [1] => s [2] => d [3] => f )
Are there commas between parameters?
But this is also an empty array?