Jump to content

Cut apart a string


Perad

Recommended Posts

The key part of this string is the following...

 

item_name1=Call+Out+Fee+for+14%3A00+on+29%2F8%2F2007

 

The whole string is...

 

cmd=_notify-validate&mc_gross=15.00&address_status=confirmed&item_number1=&payer_id=6DTZKXWN73SLS&tax=0.00&address_street=1+Main+St&payment_date=02%3A53%3A38+Aug+29%2C+2007+PDT&payment_status=Pending&charset=windows-1252&address_zip=95131&mc_shipping=0.00&mc_handling=0.00&first_name=Test&address_country_code=US&address_name=Test+User&notify_version=2.4&custom=&payer_status=verified&business=seller_1187360634_biz%40jasonstanley.co.uk&address_country=United+States&num_cart_items=1&mc_handling1=0.00&address_city=San+Jose&verify_sign=AiPC9BjkCyDFQXbSkoZcgqH3hpacAJvfpUVvvwMlmlDbAyd2PSFZvIlt&payer_email=contac_1187360562_per%40jasonstanley.co.uk&mc_shipping1=0.00&txn_id=2XR83823PR178182S&payment_type=echeck&last_name=User&address_state=CA&item_name1=Call+Out+Fee+for+14%3A00+on+29%2F8%2F2007&receiver_email=seller_1187360634_biz%40jasonstanley.co.uk&quantity1=1&receiver_id=7SLSUMDBHZCFY&pending_reason=echeck&txn_type=cart&mc_gross_1=15.00&mc_currency=USD&residence_country=US&test_ipn=1&payment_gross=15.00

 

I need to get out the Call+Out+Fee+for+14%3A00+on+29%2F8%2F2007. I can tidy this up myself, its just a case of actually getting it out of the big string. The content changes so ideally I need something which will cut between "item_name1=" and "&".

 

I need to do this a few times and once I learn to do it once I can do it for the rest.

 

 

Link to comment
https://forums.phpfreaks.com/topic/67212-cut-apart-a-string/
Share on other sites

try

<?php
$whole_string = 'cmd=_notify-validate&mc_gross=15.00&address_status=confirmed&item_number1=&payer_id=6DTZKXWN73SLS&tax=0.00&address_street=1+Main+St&payment_date=02%3A53%3A38+Aug+29%2C+2007+PDT&payment_status=Pending&charset=windows-1252&address_zip=95131&mc_shipping=0.00&mc_handling=0.00&first_name=Test&address_country_code=US&address_name=Test+User&notify_version=2.4&custom=&payer_status=verified&business=seller_1187360634_biz%40jasonstanley.co.uk&address_country=United+States&num_cart_items=1&mc_handling1=0.00&address_city=San+Jose&verify_sign=AiPC9BjkCyDFQXbSkoZcgqH3hpacAJvfpUVvvwMlmlDbAyd2PSFZvIlt&payer_email=contac_1187360562_per%40jasonstanley.co.uk&mc_shipping1=0.00&txn_id=2XR83823PR178182S&payment_type=echeck&last_name=User&address_state=CA&item_name1=Call+Out+Fee+for+14%3A00+on+29%2F8%2F2007&receiver_email=seller_1187360634_biz%40jasonstanley.co.uk&quantity1=1&receiver_id=7SLSUMDBHZCFY&pending_reason=echeck&txn_type=cart&mc_gross_1=15.00&mc_currency=USD&residence_country=US&test_ipn=1&payment_gross=15.00';
preg_match('/item_name1[^&]+/', $whole_string, $out);
$part = $out[0];
echo $part;
?>

Link to comment
https://forums.phpfreaks.com/topic/67212-cut-apart-a-string/#findComment-337115
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.