Converting arrays to string in PHP -
i trying add values comes off database using method count
; method works , using array give me proper count. trying add values code blocks coming up:
$value1 = mysqli_query($con,"select count(column) table"); $value1print = mysqli_fetch_array($value1); $value2=mysqli_query($con,"select count(column) table"); $value2print= mysqli_fetch_array($value2);
i print value these arrays using code block:
echo $value1[0]; echo $value2[0];
now i'm trying add values value1
& value2
, i've tried following functions:
implode
:
$arraytostring=implode($value1);
this method returns data in manner: if value1
1
, , value2
2
, returns 11
, 22
, when added, return 33
. wrong because obviously, need 3
.
serialize
:
$arraytostring=serialized($value1);
my count
method returns number of rows or data database has, ie: 1
or 2
.. etc. etc.; want values add up, ie: if value1
1
, value2
2
, 1+2
, come result, in example, 3
.
the below should work commented:
$totalofvalues = $value1[0] + $value2[0];
thanks
Comments
Post a Comment