PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 12, 2022

[FIXED] How do I read / get contents of a text message body?

 July 12, 2022     messages, php, sms, sms-gateway     No comments   

Issue

I'm going to use a SMS to Web Server, which will forward incoming text messages to my web server.

The message body will contain some short codes, a mobile number and a amount in a format. I need to store the details separately to variables.

Here's an example, what I will receive in my web server through POST method:

$sender = "9999912345";
$date = "2017-04-14 13:04:40";
$message = "RCG ARTL 9700012345 50";

I need to store the contents of $message separately to variables:

$cmd = "RCG";
$op = "ARTL";
$no = "9700012345";
$amt = "50";

Please help!


Solution

<?php
    $message = "RCG ARTL 9700012345 50";
    list($cmd, $op, $no, $amt) = explode(" ",$message);

you can test it.



Answered By - nprog
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing