ballhogjoni Posted December 3, 2008 Share Posted December 3, 2008 I want to turn this int 2, into an array like this: array(0=>1,1=>2); how would I do that? Link to comment https://forums.phpfreaks.com/topic/135288-whats-the-function-to-do-this/ Share on other sites More sharing options...
zenag Posted December 3, 2008 Share Posted December 3, 2008 $a=range(1,2); print_r($a); Link to comment https://forums.phpfreaks.com/topic/135288-whats-the-function-to-do-this/#findComment-704710 Share on other sites More sharing options...
ballhogjoni Posted December 3, 2008 Author Share Posted December 3, 2008 the problem is that the int 2 will change all the time. Link to comment https://forums.phpfreaks.com/topic/135288-whats-the-function-to-do-this/#findComment-705539 Share on other sites More sharing options...
Mchl Posted December 3, 2008 Share Posted December 3, 2008 Still valid $i = 4 $a = range(1,$i); print_r($a); Link to comment https://forums.phpfreaks.com/topic/135288-whats-the-function-to-do-this/#findComment-705541 Share on other sites More sharing options...
ardyandkari Posted December 4, 2008 Share Posted December 4, 2008 what is the int? is it a number of entries in a db? if so you can do this: $sql="SELECT * FROM table"; $result=mysql_query($query); $int=mysql_num_rows($result); $a = range(1,$int); print_r($a); if you were more specific as to where you were getting your number that would help... Link to comment https://forums.phpfreaks.com/topic/135288-whats-the-function-to-do-this/#findComment-705589 Share on other sites More sharing options...
corbin Posted December 4, 2008 Share Posted December 4, 2008 what is the int? is it a number of entries in a db? if so you can do this: $sql="SELECT * FROM table"; $result=mysql_query($query); $int=mysql_num_rows($result); $a = range(1,$int); print_r($a); if you were more specific as to where you were getting your number that would help... Don't take this the wrong way, but that's a horrible way to do that. SELECT COUNT(*) FROM table; Would be many times faster. Why select everything when you just want to count it? Link to comment https://forums.phpfreaks.com/topic/135288-whats-the-function-to-do-this/#findComment-705611 Share on other sites More sharing options...
ardyandkari Posted December 4, 2008 Share Posted December 4, 2008 because i am stupid, duh! no...i am pretty new to the coding thing, just a hobby...starting to get a handle on php, still not too good w/mysql. just basics. i appreciate it when someone points out something that works better/faster/smarter. i have noticed that even if i can get something done, someone else can get it done in at least half the time, if not less...either way, the idea was there and he got a crappy way and a good way to do it. use the good way! i know i will from now on. Link to comment https://forums.phpfreaks.com/topic/135288-whats-the-function-to-do-this/#findComment-705618 Share on other sites More sharing options...
corbin Posted December 4, 2008 Share Posted December 4, 2008 Link to comment https://forums.phpfreaks.com/topic/135288-whats-the-function-to-do-this/#findComment-705633 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.