NebuJohn Posted August 2, 2013 Share Posted August 2, 2013 I have retrived a set of numbers from a device, I divided it into two parts and compared if that exist in a table. When i gave a random array it worked properly. Below I give the code. <?php $array=$_POST['tel']; //numbers fetched from contact of mobile $jstring = (array)json_decode($array,JSON_FORCE_OBJECT); $ttutt =implode("','", $jstring); $tet = explode(',', $ttutt); foreach( $tet as $value ) //loop over values { $four = mb_substr($value, 0,-10); //to get the first chara's $ten = mb_substr($value, -10); // to get the last ten chara $corn=mysqli_connect("localhost","bukado","********","frocd"); //connection to the database $result = mysqli_query($corn, "SELECT * From prip WHERE nob IN ($ten) AND cdac IN ($four)"); while($row = mysqli_fetch_array($result, MYSQL_ASSOC)) { $forl[] = $row[no]; } mysqli_close($corn); } ?> Can any body please help me? any help will be appreciable. Regards. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/280755-probelm-with-exploded-array/ Share on other sites More sharing options...
AbraCadaver Posted August 2, 2013 Share Posted August 2, 2013 I have no idea what you are doing, but JSON_FORCE_OBJECT is not part of json_decode(). This is an option that controls whether you get objects or arrays, look it up. Also, look at where you encode it and encode as array or object. Why implode() and then explode()? Quote Link to comment https://forums.phpfreaks.com/topic/280755-probelm-with-exploded-array/#findComment-1443153 Share on other sites More sharing options...
NebuJohn Posted August 5, 2013 Author Share Posted August 5, 2013 I had to implode and explode because it have to be comma seperated. I have to retrive each contacts from mobile contacts from an android device. Quote Link to comment https://forums.phpfreaks.com/topic/280755-probelm-with-exploded-array/#findComment-1443499 Share on other sites More sharing options...
cyberRobot Posted August 5, 2013 Share Posted August 5, 2013 Have you checked that the variables contain expected values? For example, what do you get for the following: <?php $array=$_POST['tel']; //numbers fetched from contact of mobile print '<pre>' . print_r($array, true) . '</pre>'; $jstring = (array)json_decode($array,JSON_FORCE_OBJECT); print '<pre>' . print_r($jstring, true) . '</pre>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/280755-probelm-with-exploded-array/#findComment-1443533 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.