Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
extract array details
Old 02-09-2011, 11:23 AM extract array details
Extreme Talker

Posts: 173
Trades: 0
I am posting details from a form; however, the form I am using can draw in details from several different sources. Now the problem I have is to determine what was my data source.

I can use foreach to provide the value of each data point but how can I get the name of the data point?

name=tbl_sod.sod_id
data=1871

Quote:
Array ( [tbl_sod.sod_id] => 1871 [doc] => 3418499-015 [rev] => B [doc_desc] => SKID HARDWARE LIST [required_status] => [esod] => 1 [isod] => 1 [pages] => 1 [status] => [eng_error] => 11 [draft_error] => 21 [vendor_error] => 31 [sourcing_error] => 41 [value_eng] => 51 [requested_change] => 61 [spec_conflict] => 71 [direction_deficient] => 81 [schedule_issue] => 91 [mfg_error] => 101 [comment] => HELLO )
dgkindy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-09-2011, 12:28 PM Re: extract array details
Extreme Talker

Posts: 173
Trades: 0
What is being identified is call the key. The following function will return the key.

key()
dgkindy is offline
Reply With Quote
View Public Profile
 
Old 02-09-2011, 01:05 PM Re: extract array details
Extreme Talker

Posts: 173
Trades: 0
Cannot use the foreach and key function together.

Here is what I developed in the end

PHP Code:
if(!empty($_POST)){
 
$sql='UPDATE '.key($_POST).' SET '
 while(list(
$key,$val)=each($_POST)){
  if(!empty(
$val)) $sql.=$key.'='.strtoupper(mysql_real_escape_string($val)).' '
  else    
$sql.=$key.'=NULL '
 }
 
reset($_POST);
 
$sql.='WHERE '.key($_POST).'='.$_POST[key($_POST)];
 echo 
$sql;
// $result=query($sql);

dgkindy is offline
Reply With Quote
View Public Profile
 
Old 02-09-2011, 03:02 PM Re: extract array details
Super Spam Talker

Posts: 880
Name: Paul W
Trades: 0
foreach ($arr as $key => $value) { echo "Key: $key; Value: $value
";}
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to extract array details
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.80548 seconds with 12 queries