Search Results

Search found 1 results on 1 pages for 'carpetfizz'.

Page 1/1 | 1 

  • Adding different objects to array, but only one object repeating

    - by Carpetfizz
    I have a small piece of PHP code that goes through valid values and fetches information about them. It then pushes it to an array. For some reason, I'm only getting the last item of $row, repeated several times. When I try to print_r at #1 in the code, the expected values are outputted. However, at the end of the loop, or outside of it, when I try to print_r($ipArray), I'm only getting the last value repeated multiple times. Any help would be much appreciated! while($row = mysqli_fetch_array($getIpQuery, MYSQLI_NUM)){ for($x=0;$x<count($row);$x++) { $getIpInfo = mysqli_query($dbcon, "SELECT * FROM ipInfo WHERE address='$row[$x]'"); $retrievedInfo = mysqli_fetch_array($getIpInfo, MYSQLI_NUM); $ipInfo->ipAddress = $retrievedInfo[0]; $ipInfo->portNum = $retrievedInfo[1]; print_r($ipInfo); //#1: Works perfectly fine. array_push($ipArray,$ipInfo); } } print_r($ipArray); //this is where I'm getting an output of only the last element of `$row`. Thanks! ~Carpetfizz

    Read the article

1