Multiple For each loop value to Json stringCustom Design/Layout for Simple ProductsExclude a specific categoryCreate categories through installerRemoving value from arrayHow To Fetch And Display Last 4 Table Rows?Magento2 - How to get JSON response from ControllerGet order data by product id Magento 1.9Overriding Core File in MagentoMagento 1 - Convert Object into an array valueConvert(re-write) array_filter code into foreach loop
Is there any mention of ghosts who live outside the Hogwarts castle?
Which values for voltage divider
Nunc est bibendum: gerund or gerundive?
Find this Unique UVC Palindrome ( ignoring signs and decimal) from Given Fractional Relationship
Can someone get a spouse off a deed that never lived together and was incarcerated?
Writing "hahaha" versus describing the laugh
Split into three!
One word for 'the thing that attracts me'?
Why the work done is positive when bringing 2 opposite charges together?
size of pointers and architecture
Is being an extrovert a necessary condition to be a manager?
Does attacking (or having a rider attack) cancel Charge/Pounce-like abilities?
What is this dime sized black bug with white on the segments near Loveland Colorodao?
Why "strap-on" boosters, and how do other people say it?
Computing elements of a 1000 x 60 matrix exhausts RAM
Singular Integration
Can diplomats be allowed on the flight deck of a commercial European airline?
Can the Conjure Barrage spell stack with the Disarming Attack or Trip Attack Battle Master maneuvers?
Salesforce bug enabled "Modify All"
How to make Flex Markers appear in Logic Pro X?
What was the primary motivation for a historical figure like Xenophon to create an extensive collection of written material?
(For training purposes) Are there any openings with rook pawns that are more effective than others (and if so, what are they)?
Why is 'additive' EQ more difficult to use than 'subtractive'?
Managing heat dissipation in a magic wand
Multiple For each loop value to Json string
Custom Design/Layout for Simple ProductsExclude a specific categoryCreate categories through installerRemoving value from arrayHow To Fetch And Display Last 4 Table Rows?Magento2 - How to get JSON response from ControllerGet order data by product id Magento 1.9Overriding Core File in MagentoMagento 1 - Convert Object into an array valueConvert(re-write) array_filter code into foreach loop
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$data= array();
foreach($itfdatas as $key=>$itfdata)
$checkemps = explode(',',$itfdata['employee_id']);
$data[] = array(
'id'=>mysql_real_escape_string($itfdata['P_id']),
'job_id'=>mysql_real_escape_string($itfdata['quote_id']),
'job_title'=>mysql_real_escape_string($itfdata['job_title']));
foreach ($checkemps as $checkempss)
$empusers = $users->ShowAllEmployeeByJobId($checkempss['profile_id']);
$data[] =array(
'helper_id'=>mysql_real_escape_string($empusers['profile_id']),
'helper_name'=>mysql_real_escape_string($empusers['name']));
$msg=array('status'=>'success','emp_job_list'=>$data);
$itfresinfo=json_encode($msg);
echo $itfresinfo;
The above code gives the below output
"status": "success",
"emp_job_list": [
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck"
,
"helper_id": "1",
"helper_name": "Vivek"
,
"helper_id": "3",
"helper_name": "Akhilesh"
,
"id": "2",
"job_id": "MM/IR2",
"job_title": "This is the test asasascvcvcv"
,
"helper_id": "1",
"helper_name": "Vivek"
,
"helper_id": "3",
"helper_name": "Akhilesh"
]
But I want the below output
"status": "success",
"emp_job_list": [
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck",
"helper_detail":[
"helper_id": "1",
"helper_name": "Vivek"
]
,
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck",
"helper_detail":[
"helper_id": "1",
"helper_name": "Vivek"
]
]
php json array
add a comment |
$data= array();
foreach($itfdatas as $key=>$itfdata)
$checkemps = explode(',',$itfdata['employee_id']);
$data[] = array(
'id'=>mysql_real_escape_string($itfdata['P_id']),
'job_id'=>mysql_real_escape_string($itfdata['quote_id']),
'job_title'=>mysql_real_escape_string($itfdata['job_title']));
foreach ($checkemps as $checkempss)
$empusers = $users->ShowAllEmployeeByJobId($checkempss['profile_id']);
$data[] =array(
'helper_id'=>mysql_real_escape_string($empusers['profile_id']),
'helper_name'=>mysql_real_escape_string($empusers['name']));
$msg=array('status'=>'success','emp_job_list'=>$data);
$itfresinfo=json_encode($msg);
echo $itfresinfo;
The above code gives the below output
"status": "success",
"emp_job_list": [
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck"
,
"helper_id": "1",
"helper_name": "Vivek"
,
"helper_id": "3",
"helper_name": "Akhilesh"
,
"id": "2",
"job_id": "MM/IR2",
"job_title": "This is the test asasascvcvcv"
,
"helper_id": "1",
"helper_name": "Vivek"
,
"helper_id": "3",
"helper_name": "Akhilesh"
]
But I want the below output
"status": "success",
"emp_job_list": [
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck",
"helper_detail":[
"helper_id": "1",
"helper_name": "Vivek"
]
,
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck",
"helper_detail":[
"helper_id": "1",
"helper_name": "Vivek"
]
]
php json array
add a comment |
$data= array();
foreach($itfdatas as $key=>$itfdata)
$checkemps = explode(',',$itfdata['employee_id']);
$data[] = array(
'id'=>mysql_real_escape_string($itfdata['P_id']),
'job_id'=>mysql_real_escape_string($itfdata['quote_id']),
'job_title'=>mysql_real_escape_string($itfdata['job_title']));
foreach ($checkemps as $checkempss)
$empusers = $users->ShowAllEmployeeByJobId($checkempss['profile_id']);
$data[] =array(
'helper_id'=>mysql_real_escape_string($empusers['profile_id']),
'helper_name'=>mysql_real_escape_string($empusers['name']));
$msg=array('status'=>'success','emp_job_list'=>$data);
$itfresinfo=json_encode($msg);
echo $itfresinfo;
The above code gives the below output
"status": "success",
"emp_job_list": [
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck"
,
"helper_id": "1",
"helper_name": "Vivek"
,
"helper_id": "3",
"helper_name": "Akhilesh"
,
"id": "2",
"job_id": "MM/IR2",
"job_title": "This is the test asasascvcvcv"
,
"helper_id": "1",
"helper_name": "Vivek"
,
"helper_id": "3",
"helper_name": "Akhilesh"
]
But I want the below output
"status": "success",
"emp_job_list": [
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck",
"helper_detail":[
"helper_id": "1",
"helper_name": "Vivek"
]
,
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck",
"helper_detail":[
"helper_id": "1",
"helper_name": "Vivek"
]
]
php json array
$data= array();
foreach($itfdatas as $key=>$itfdata)
$checkemps = explode(',',$itfdata['employee_id']);
$data[] = array(
'id'=>mysql_real_escape_string($itfdata['P_id']),
'job_id'=>mysql_real_escape_string($itfdata['quote_id']),
'job_title'=>mysql_real_escape_string($itfdata['job_title']));
foreach ($checkemps as $checkempss)
$empusers = $users->ShowAllEmployeeByJobId($checkempss['profile_id']);
$data[] =array(
'helper_id'=>mysql_real_escape_string($empusers['profile_id']),
'helper_name'=>mysql_real_escape_string($empusers['name']));
$msg=array('status'=>'success','emp_job_list'=>$data);
$itfresinfo=json_encode($msg);
echo $itfresinfo;
The above code gives the below output
"status": "success",
"emp_job_list": [
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck"
,
"helper_id": "1",
"helper_name": "Vivek"
,
"helper_id": "3",
"helper_name": "Akhilesh"
,
"id": "2",
"job_id": "MM/IR2",
"job_title": "This is the test asasascvcvcv"
,
"helper_id": "1",
"helper_name": "Vivek"
,
"helper_id": "3",
"helper_name": "Akhilesh"
]
But I want the below output
"status": "success",
"emp_job_list": [
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck",
"helper_detail":[
"helper_id": "1",
"helper_name": "Vivek"
]
,
"id": "1",
"job_id": "MM/IR1",
"job_title": "2 Men with 4.5 Tonne Truck",
"helper_detail":[
"helper_id": "1",
"helper_name": "Vivek"
]
]
php json array
php json array
asked May 15 at 5:12
SheenuSheenu
6912
6912
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Try it like this. But watch out for typos. I haven't tested it.
If this does not work, add to the question a sample of how $itfdatas
looks like and one of what $users->ShowAllEmployeeByJobId($checkempss['profile_id'])
returns.
$data= array();
foreach($itfdatas as $key=>$itfdata)
$employee = array(
'id' => mysql_real_escape_string($itfdata['P_id']),
'job_id' => mysql_real_escape_string($itfdata['quote_id']),
'job_title' => mysql_real_escape_string($itfdata['job_title'])
'helper_detail' => array();
);
$checkemps = explode(',',$itfdata['employee_id']);
foreach ($checkemps as $checkempss)
$empusers = $users->ShowAllEmployeeByJobId($checkempss['profile_id']);
$employee['helper_detail'][] = array(
'helper_id' => mysql_real_escape_string($empusers['profile_id']),
'helper_name' => mysql_real_escape_string($empusers['name'])
);
$data[] = $employee;
$msg = array('status' => 'success','emp_job_list' => $data);
$itfresinfo = json_encode($msg);
echo $itfresinfo;
$itfdatas looks like below Array ( [0] => Array ( [id] => 1 [job_id] => MM/IR1 [job_title] => 2 Men with 4.5 Tonne Truck ) [1] => Array ( [id] => 2 [job_id] => MM/IR2 [job_title] => 3 Men with 4.5 Tonne Truck ) )
– Sheenu
May 15 at 5:31
Thanks for you quick Answer
– Sheenu
May 15 at 5:48
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f274613%2fmultiple-for-each-loop-value-to-json-string%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try it like this. But watch out for typos. I haven't tested it.
If this does not work, add to the question a sample of how $itfdatas
looks like and one of what $users->ShowAllEmployeeByJobId($checkempss['profile_id'])
returns.
$data= array();
foreach($itfdatas as $key=>$itfdata)
$employee = array(
'id' => mysql_real_escape_string($itfdata['P_id']),
'job_id' => mysql_real_escape_string($itfdata['quote_id']),
'job_title' => mysql_real_escape_string($itfdata['job_title'])
'helper_detail' => array();
);
$checkemps = explode(',',$itfdata['employee_id']);
foreach ($checkemps as $checkempss)
$empusers = $users->ShowAllEmployeeByJobId($checkempss['profile_id']);
$employee['helper_detail'][] = array(
'helper_id' => mysql_real_escape_string($empusers['profile_id']),
'helper_name' => mysql_real_escape_string($empusers['name'])
);
$data[] = $employee;
$msg = array('status' => 'success','emp_job_list' => $data);
$itfresinfo = json_encode($msg);
echo $itfresinfo;
$itfdatas looks like below Array ( [0] => Array ( [id] => 1 [job_id] => MM/IR1 [job_title] => 2 Men with 4.5 Tonne Truck ) [1] => Array ( [id] => 2 [job_id] => MM/IR2 [job_title] => 3 Men with 4.5 Tonne Truck ) )
– Sheenu
May 15 at 5:31
Thanks for you quick Answer
– Sheenu
May 15 at 5:48
add a comment |
Try it like this. But watch out for typos. I haven't tested it.
If this does not work, add to the question a sample of how $itfdatas
looks like and one of what $users->ShowAllEmployeeByJobId($checkempss['profile_id'])
returns.
$data= array();
foreach($itfdatas as $key=>$itfdata)
$employee = array(
'id' => mysql_real_escape_string($itfdata['P_id']),
'job_id' => mysql_real_escape_string($itfdata['quote_id']),
'job_title' => mysql_real_escape_string($itfdata['job_title'])
'helper_detail' => array();
);
$checkemps = explode(',',$itfdata['employee_id']);
foreach ($checkemps as $checkempss)
$empusers = $users->ShowAllEmployeeByJobId($checkempss['profile_id']);
$employee['helper_detail'][] = array(
'helper_id' => mysql_real_escape_string($empusers['profile_id']),
'helper_name' => mysql_real_escape_string($empusers['name'])
);
$data[] = $employee;
$msg = array('status' => 'success','emp_job_list' => $data);
$itfresinfo = json_encode($msg);
echo $itfresinfo;
$itfdatas looks like below Array ( [0] => Array ( [id] => 1 [job_id] => MM/IR1 [job_title] => 2 Men with 4.5 Tonne Truck ) [1] => Array ( [id] => 2 [job_id] => MM/IR2 [job_title] => 3 Men with 4.5 Tonne Truck ) )
– Sheenu
May 15 at 5:31
Thanks for you quick Answer
– Sheenu
May 15 at 5:48
add a comment |
Try it like this. But watch out for typos. I haven't tested it.
If this does not work, add to the question a sample of how $itfdatas
looks like and one of what $users->ShowAllEmployeeByJobId($checkempss['profile_id'])
returns.
$data= array();
foreach($itfdatas as $key=>$itfdata)
$employee = array(
'id' => mysql_real_escape_string($itfdata['P_id']),
'job_id' => mysql_real_escape_string($itfdata['quote_id']),
'job_title' => mysql_real_escape_string($itfdata['job_title'])
'helper_detail' => array();
);
$checkemps = explode(',',$itfdata['employee_id']);
foreach ($checkemps as $checkempss)
$empusers = $users->ShowAllEmployeeByJobId($checkempss['profile_id']);
$employee['helper_detail'][] = array(
'helper_id' => mysql_real_escape_string($empusers['profile_id']),
'helper_name' => mysql_real_escape_string($empusers['name'])
);
$data[] = $employee;
$msg = array('status' => 'success','emp_job_list' => $data);
$itfresinfo = json_encode($msg);
echo $itfresinfo;
Try it like this. But watch out for typos. I haven't tested it.
If this does not work, add to the question a sample of how $itfdatas
looks like and one of what $users->ShowAllEmployeeByJobId($checkempss['profile_id'])
returns.
$data= array();
foreach($itfdatas as $key=>$itfdata)
$employee = array(
'id' => mysql_real_escape_string($itfdata['P_id']),
'job_id' => mysql_real_escape_string($itfdata['quote_id']),
'job_title' => mysql_real_escape_string($itfdata['job_title'])
'helper_detail' => array();
);
$checkemps = explode(',',$itfdata['employee_id']);
foreach ($checkemps as $checkempss)
$empusers = $users->ShowAllEmployeeByJobId($checkempss['profile_id']);
$employee['helper_detail'][] = array(
'helper_id' => mysql_real_escape_string($empusers['profile_id']),
'helper_name' => mysql_real_escape_string($empusers['name'])
);
$data[] = $employee;
$msg = array('status' => 'success','emp_job_list' => $data);
$itfresinfo = json_encode($msg);
echo $itfresinfo;
answered May 15 at 5:23
Marius♦Marius
169k28326697
169k28326697
$itfdatas looks like below Array ( [0] => Array ( [id] => 1 [job_id] => MM/IR1 [job_title] => 2 Men with 4.5 Tonne Truck ) [1] => Array ( [id] => 2 [job_id] => MM/IR2 [job_title] => 3 Men with 4.5 Tonne Truck ) )
– Sheenu
May 15 at 5:31
Thanks for you quick Answer
– Sheenu
May 15 at 5:48
add a comment |
$itfdatas looks like below Array ( [0] => Array ( [id] => 1 [job_id] => MM/IR1 [job_title] => 2 Men with 4.5 Tonne Truck ) [1] => Array ( [id] => 2 [job_id] => MM/IR2 [job_title] => 3 Men with 4.5 Tonne Truck ) )
– Sheenu
May 15 at 5:31
Thanks for you quick Answer
– Sheenu
May 15 at 5:48
$itfdatas looks like below Array ( [0] => Array ( [id] => 1 [job_id] => MM/IR1 [job_title] => 2 Men with 4.5 Tonne Truck ) [1] => Array ( [id] => 2 [job_id] => MM/IR2 [job_title] => 3 Men with 4.5 Tonne Truck ) )
– Sheenu
May 15 at 5:31
$itfdatas looks like below Array ( [0] => Array ( [id] => 1 [job_id] => MM/IR1 [job_title] => 2 Men with 4.5 Tonne Truck ) [1] => Array ( [id] => 2 [job_id] => MM/IR2 [job_title] => 3 Men with 4.5 Tonne Truck ) )
– Sheenu
May 15 at 5:31
Thanks for you quick Answer
– Sheenu
May 15 at 5:48
Thanks for you quick Answer
– Sheenu
May 15 at 5:48
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f274613%2fmultiple-for-each-loop-value-to-json-string%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown