0

i want to get return values in php $variables

what i get now is like this

ok true 10007.20 cd3f2d61-c929-4a6e-a587-33878fb2b836 200

while i want to get it in variable:

  • $value1 = 'ok';
  • $value2 = 'true';
  • $value3 = '10007.20';

    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL,"https://www.smsbox.com/SMSGateway/Services/Messaging.asmx/Http_SendSMS");
    
    curl_setopt($ch, CURLOPT_POST, 1);
    
    curl_setopt($ch, CURLOPT_POSTFIELDS,"username=".$username."&password=".$password."&customerId=".$cutomerId."&senderText=".$senderText."&messageBody=".$messageBody."&recipientNumbers=".$recipientNumbers."&defdate=&isBlink=false&isFlash=false");
    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $content = curl_exec($ch);
    echo $content;
    
    curl_close ($ch); 
    

echo htmlentities($content);

ok true 10005.20 4ce81f05-31cb-40c4-93e2-fd68bf50fc23 version="1.0" encoding="utf-8"?> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://itbsms.com/"> ok true 10006.20 3320429f-59b8-47fc-a49e-3e209a472b16 />

1 Answer 1

0

Use explode to get the values in an array:

$values = explode(' ', $content);
Sign up to request clarification or add additional context in comments.

5 Comments

Array ( [0] => version="1.0" [2] => encoding="utf-8"?> xmlns:xsi="w3.org/2001/XMLSchema-instance" [4] => xmlns:xsd="w3.org/2001/XMLSchema" [5] => xmlns="itbsms.com"> [6] => [7] => ok [8] => [9] => true [10] => [11] => 10006.20 [12] => [13] => 3320429f-59b8-47fc-a49e-3e209a472b16 [14] => [15] => /> )
@user3127434 I assumed that $content was just ok true 10007.20 cd3f2d61-c929-4a6e-a587-33878fb2b836 200. You should have provided the full output of the $content variable. Please update your question.
i don't now about that! ... i update it now ... as i see it's XML ... is there away to get varaible from it ??
@user3127434 instead of doing echo $content; do echo htmlentities($content); and update the question with the exact output.
<?xml version="1.0" encoding="utf-8"?> <SendingSMSResult xmlns:xsi="w3.org/2001/XMLSchema-instance" xmlns:xsd="w3.org/2001/XMLSchema" xmlns="itbsms.com"> <Message>ok</Message> <Result>true</Result> <NetPoints>10005.20</NetPoints> <messageId>4ce81f05-31cb-40c4-93e2-fd68bf50fc23</messageId> <RejectedNumbers /> </SendingSMSResult> version="1.0" encoding="utf-8"?> xmlns:xsi="w3.org/2001/XMLSchema-instance" xmlns:xsd="w3.org/2001/XMLSchema" xmlns="itbsms.com"> ok true 10006.20 3320429f-59b8-47fc-a49e-3e209a472b16 />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.