|
Posted by Mladen Gogala on 11/27/06 07:37
On Sun, 26 Nov 2006 21:54:36 +0100, Michael Fesser wrote:
> Works here on PHP 5.2. What version do you use?
No, it doesn't:
$ /tmp/ttt
PHP Notice: Array to string conversion in /tmp/ttt on line 4
$
$
$ cat /tmp/ttt
#!/usr/local/bin/php
<?php
$zee=array(3,4,5);
settype($zee, "string");
if (($zee[0] % 2 != 0) && ($zee[1] % 2 == 0))
{
echo $zee . "<br />";
}
?>
$ /usr/local/bin/php -v
PHP 5.2.0 (cli) (built: Nov 3 2006 21:13:54)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
What he wants is to convert array to string for faster printing, sort like
the equivalence between char[] and *char in C language. He has an array of
integers and wants to print them as a string, provided certain numeric
conditions are met. That is why I broke a string into an array in my
snippet. In other words, he wants to be smart with "settype" function.
--
http://www.mladen-gogala.com
Navigation:
[Reply to this message]
|