Hi,

I have a problem to split and get the value in string. here example output

--_BeginData_
payeeId=xxxx
channelId=ECEP
billAccountNo=exb111109-315262
billReferenceNo=TOPUP20111109200257
amount=42
paymentRefNo=61417686
transactionDate=20111109
transactionTime=194843
userFullName=KHOR JO FENG
status=S
--_EndData_

In above example,

i need output for payeeId=xxxx, billAccountNo=exb111109-315262, billReferenceNo=TOPUP20111109200257 and etc.,

so i want value after the equal. It means i need xxxx and exb111109-315262 and etc.,

how can i get it and reply asap. Tq.

William.

<?php
$string="--_BeginData_
payeeId=xxxx
channelId=ECEP
billAccountNo=exb111109-315262
billReferenceNo=TOPUP20111109200257
amount=42
paymentRefNo=61417686
transactionDate=20111109
transactionTime=194843
userFullName=KHOR JO FENG
status=S
--_EndData_";


$data=split("\n", $string);
echo "<pre>";
print_r($data);
echo "</pre>";

for ($i=1;$i<=10;$i++)
{
	$rec=split("=", $data[$i]);	
	echo $rec[1]."<br>";
}


?>
Member Avatar for diafol

WRT use of split(), from php.net:

This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.

maybe try:

echo str_replace("\n",", ",substr($string,15,-13));

You avoid using loops and arrays. Perhaps "\n" won't work, if not try "\n\r".

Hi,

Thank you friends. Now working well.

Member Avatar for diafol

Mark it as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.