Link to home
Start Free TrialLog in
Avatar of Hamdan Shafiq
Hamdan ShafiqFlag for Pakistan

asked on

how can check integer or string value in array

<?php
function get_data($url){
   $ch = curl_init();
  $timeout = 0;
  curl_setopt ($ch, CURLOPT_URL, $url);
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  $response=json_decode(curl_exec($ch),true);
	curl_close($ch);
    return $response;
}

$url='http://212.76.95.85:8844/CreateHWB.aspx?from=RYD&to=DMM&shipid=1223456789&shipssn=0&shipname=mohamad&shipphone=098765&shipcity=riyadh&shipaddress=Riyadh-Olayia&rcvssn=0&rcvname=toto&rcvphone=0546445819&rcvcity=dammam&rcvaddress=dammam-Raka%20&pkgdesc=IPHONE&codvalue=1700&pcs=1&customerno=110004&weight=3&passcode=TestPassword&refno=0';
$response=get_data($url);
print_r($response);
if(is_int($response[0][0]==true)) {
$$object=$response[0][0];
}else{
$object=$response[0][0];
echo '<font color="#cc0000">message:: '.$object.'</font>';
	exit();
}

?>

Open in new window

Avatar of Leonidas Dosas
Leonidas Dosas
Flag of Greece image

The general method to do this is via gettype() method ie:
$data = array(1, 1., NULL, new stdClass, 'foo');

foreach ($data as $value) {
    echo gettype($value), "\n";
}

Open in new window

Now in your php code wich is the array var?
ASKER CERTIFIED SOLUTION
Avatar of NerdsOfTech
NerdsOfTech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial