I have a for each loop that is looping through an array of data –
foreach ($products as $value){
$product_id = $correlationId;
$pid = mysql_escape_string($value['ProductId']);
$dname = mysql_real_escape_string($value['departmentName']);
$cname = mysql_real_escape_string($value['categoryName']);
$pname = mysql_real_escape_string($value['productName']);
$price = mysql_real_escape_string($value['productPrice']);
$qty = mysql_real_escape_string($value['productQty']);
//Insert Product data into DB
$insert_product = "INSERT INTO product(department_name,category_name,product_name,product_price,product_qty)VALUES('$dname','$cname','$pname','$price','$qty')";
$insert_result = mysql_query($insert_product);
if(mysql_insert_id() > 0){
$response = array('CorrelationId'=>$pid,
'Messages'=> array('Has been added.')
);
return $response;
}
}
I am really looking on information to best return $response without stopping the loop. I would like it to return the data then carry back on with the loop then return the data then carry back on with the loop.
Currently It stops after the first return, obviously becasue the return is breaking it?
Can anyone shed some light for me?
Thanks
Edit – Extra Code added
//Create complex type for StringArray
$server->wsdl->addComplexType(
'StringArray',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]')),
'xsd:string'
);
//Create complex type for AddProductResponce
$server->wsdl->addComplexType(
'AddProductResponse',
'complexType',
'struct',
'all',
'',
array(
'CorrelationId' => array('name'=>'CorrelationId','type'=>'xsd:string'),
'Messages' => array('name'=>'Messages','type'=>'tns:StringArray'),
)
);
Im working with a NUSAOP server and thats the complexTypes to handle the responce, I cannot seem to be able to adjust these to help aid the return after the loop
and when the loop ends reutrn it.
The difference is that now $response is an array of arrays.
Is that what you were looking for?