adv Posted September 18, 2008 Share Posted September 18, 2008 hello i have a question i have this $str= "user1,pass1,question1,user2,pass2,question2"; $res=explode(',',$str); //print_r($explode); debug i`m using curl to login but in the content of the site $vars="username=".$res[0]."&password=".$res[1]."&question=".$res[2]; and i made an input <input type="text" name="test" value="" size="100"> and in the input i can put the $str and using curl to check but i dont know how to do after $res[0] $res[1] $res[2] to continue to $res[3] $res[4] $res[5] my main goal is to check 2 users .. the only thing i dont know how to automatically go after $res[3] to $res[4] $res[5] $res[6] Link to comment https://forums.phpfreaks.com/topic/124859-count-question/ Share on other sites More sharing options...
F1Fan Posted September 18, 2008 Share Posted September 18, 2008 Do something like: <?php $numusers = count($res); if ($numusers>0){ $numusers = $numusers/3; } ?> That would give you the number of users there are. Link to comment https://forums.phpfreaks.com/topic/124859-count-question/#findComment-645078 Share on other sites More sharing options...
adv Posted September 20, 2008 Author Share Posted September 20, 2008 no this doesnt work i need somehow to count and then extract user = 1 ,2 ,3 user2 = 4 ,5 ,6 , user3 = 7 ,8 ,9 and continue further Link to comment https://forums.phpfreaks.com/topic/124859-count-question/#findComment-646325 Share on other sites More sharing options...
Zane Posted September 20, 2008 Share Posted September 20, 2008 $i = 1; foreach(explode($str, ",") as $u) { if(count(${"user" . $i})) == 3) $i++; ${"user" . $i}[] = $u; } Link to comment https://forums.phpfreaks.com/topic/124859-count-question/#findComment-646343 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.