MuffinMan wrote:
I'm trying to add up an integer with the result from substr() like
$second_int = substr( .... ) + $int;
Lookss good.
I know the result from substr() is an integer and so is $int but in the end
$second_int only has the result from the substr() and hasn't add up the
$int. What am I doing wrong in here...
No idea ...
tried quite a few things but well....
why don't you post what you tried?
$ cat xx.php
<?php
$int = 17;
$text = '01234';
$y = array();
$y[] = substr($text, 1, 2) + $int;
$y[] = substr($text, 1) + $int;
$y[] = substr($text, 1, 55) + $int;
$y[] = substr($text, 1, -2) + $int;
$y[] = substr($text, 1, -22) + $int;
$y[] = substr($text, -3, 2) + $int;
$y[] = substr($text, -3) + $int;
$y[] = substr($text, -3, 55) + $int;
$y[] = substr($text, -3, -2) + $int;
$y[] = substr($text, -3, -22) + $int;
print_r($y);
?>
$ php xx.php
Array
(
[0] => 29
[1] => 1251
[2] => 1251
[3] => 29
[4] => 17
[5] => 40
[6] => 251
[7] => 251
[8] => 19
[9] => 17
)
$
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :