How to print limit digits of long mobile number

how to print some of the mobile number (first 5 digits)!

Page 1 of 1

3 Replies - 2140 Views - Last Post: 11 February 2009 - 12:42 PM Rate Topic: ***** 1 Votes

#1 csboss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-January 09

How to print limit digits of long mobile number

Post icon  Posted 11 February 2009 - 08:25 AM

Good day every one,


My question it will be easy i assume>>>


I have mobile number, I want to minimize the output number from 15 digits upto only 12 digits by printing first 12 one's

(e.x $mobile= 966598383838332 I want to print just like this $mobile= 966598383838 ) first 12!

I want to sed sms for this number but with only 12 digits>>>

1) I tried to use substr() but isn't working because it will deal with number as string which is not acceptable

2) I tried to get this value back to integer by using $mobileback = (int)$mobile but it changes the digits to other one

here my code
<?php

include("function.php");
	
	
	
	/*$mobile = $_POST['mobileNumber'];*/
	
	$message = $_POST['message'];
	$mobile= $_POST['mobileNumber'];// mobile number after decryption = 966598393238??? // last three digits is unknow character??
	
	$mobil = substr((int)$mobile, 0, 11);//this function will print  first number in this string up to last one in string -3 but as integer will be convert to string !!!!! 
	//it will print 2147483647 
  
		 echo $mobileNum;// this will print number which is string not exist integer any more
	  
	  $num = (int)$mobil;// I use this function to convert string to be integer ,but once i did this, I get other number not orginal one.?
	  
	  echo $num;// this is just an example to see different

		  $sendsms = sendToMobile( $num, "TakeAway.Com", $message );

?>


this code didn't work to send sms cause of this problem I want to minimize mobile number to get value of first 12


This post has been edited by csboss: 11 February 2009 - 08:30 AM


Is This A Good Question/Topic? 0
  • +

Replies To: How to print limit digits of long mobile number

#2 csboss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-January 09

Re: How to print limit digits of long mobile number

Posted 11 February 2009 - 09:51 AM

ANY one have answer please help me with that

or don't understand, I wan make it more clear, if anydon't??
Was This Post Helpful? 0
  • +
  • -

#3 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3100
  • View blog
  • Posts: 10,889
  • Joined: 08-August 08

Re: How to print limit digits of long mobile number

Posted 11 February 2009 - 09:56 AM

This should make it clear:
<?php
$num ="12345678901234567890";
$shortnum = substr($num,0,12);
echo $num."<br>".$shortnum;
?> 

Was This Post Helpful? 1
  • +
  • -

#4 csboss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-January 09

Re: How to print limit digits of long mobile number

Posted 11 February 2009 - 12:42 PM

thanks very much
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1