rhijaen Posted November 1, 2008 Share Posted November 1, 2008 I'm having a problem..some of the values in my array are integer and some are "supposed" to be string. Though I think since the first are integer, when it gets to filling in a string, it knows it's not an integer so it passes 0 to the array value. Here's an example: while($newArray = mysql_fetch_array($result)){ $b_p_light[$count] = $newArray['b_p_light']; $count++; } When it gets to a string, it returns it as 0. How can I fix this to have it all strings or some integer and some string? Link to comment https://forums.phpfreaks.com/topic/131019-settype-array-to-string/ Share on other sites More sharing options...
rhijaen Posted November 1, 2008 Author Share Posted November 1, 2008 An example of one of the strings is self.true_light *25/100 They are all varchar(50) in the mysql db. Link to comment https://forums.phpfreaks.com/topic/131019-settype-array-to-string/#findComment-680228 Share on other sites More sharing options...
Jeremysr Posted November 1, 2008 Share Posted November 1, 2008 You can change an integer to a string like this: $number = 3; $string = strval($number); // $string now equals "3". Link to comment https://forums.phpfreaks.com/topic/131019-settype-array-to-string/#findComment-680237 Share on other sites More sharing options...
rhijaen Posted November 1, 2008 Author Share Posted November 1, 2008 I used if (!empty($b_p_air)) and it worked..where if ($b_p_air != 0) didn't work Link to comment https://forums.phpfreaks.com/topic/131019-settype-array-to-string/#findComment-680240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.