Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 16th, 2007, 08:43 AM
degsy degsy is offline
Contributing User
ASP Free God 2nd Plane (6000 - 6499 posts)
 
Join Date: Aug 2005
Location: North East, UK
Posts: 6,191 degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 41 m 52 sec
Reputation Power: 121
Print_r() function ASP/VBScript

Here is an example of a print_r equivalent to the PHP print_r() function in ASP VBScript.

It is not an exact match but it should work.
As with PHP if you want to specify an array element you need to add [] to the element name

Code:
<form name="form1" method="post" action="">
  <p>
    <input name="textfield" type="text" value="Joe, Bob">
</p>
  <p>
    <input name="checkbox[]" type="checkbox" value="Joe" checked>
    <input name="checkbox[]" type="checkbox" value="Bob" checked>
</p>
  <p>
    <select name="select[]" size="2" multiple>
      <option value="Joe" selected>Joe</option>
      <option value="Bob" selected>Bob</option>
    </select>
</p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>


php Code:
Original - php Code
  1. <?php
  2. print_r($_POST);
  3. ?>


asp Code:
Original - asp Code
  1. Sub print_r(a)
  2.     Response.Write "Array ("
  3.     For Each i In a
  4.         i = Trim(i)
  5.         If Right(i,2) = "[]" Then
  6.             Response.Write " [" & Left(i,Len(i)-2) & "] => Array ( "
  7.                 s = Split(a(i),",")
  8.                 For c=0 To Ubound(s)
  9.                     Response.Write " [" & c & "]" & " => " & s(c)
  10.                 Next
  11.             Response.Write " )"
  12.         Else
  13.             Response.Write " [" & i & "] => " & a(i)
  14.         End If
  15.     Next
  16.     Response.Write " )"
  17.  
  18. End Sub
  19. Call print_r(Request.Form)
__________________
CyberTechHelp

Reply With Quote
  #2  
Old February 7th, 2007, 09:51 AM
degsy degsy is offline
Contributing User
ASP Free God 2nd Plane (6000 - 6499 posts)
 
Join Date: Aug 2005
Location: North East, UK
Posts: 6,191 degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 41 m 52 sec
Reputation Power: 121
Updated version using the Request.Form Index property.

asp Code:
Original - asp Code
  1. For Each Item In Request.Form
  2.     For x=1 To Request.Form(item).Count
  3.         Response.Write Item & ": " & Request.Form(Item)(x) & "<br>"
  4.     Next
  5. Next




Using this you can do away with the [] to indicate an array that you need to use for PHP.

asp Code:
Original - asp Code
  1. Sub print_r(a)
  2.     Response.Write "Array ("
  3.     For Each i In a
  4.         i = Trim(i)
  5.         If a(i).Count > 1 Then
  6.             Response.Write " [" & i & "] => Array ( "
  7.                 For c=1 To a(i).Count
  8.                     Response.Write " [" & c-1 & "]" & " => " & a(i)(c)
  9.                 Next
  10.             Response.Write " )"
  11.         Else
  12.             Response.Write " [" & i & "] => " & a(i)
  13.         End If
  14.     Next
  15.     Response.Write " )"
  16.  
  17. End Sub

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Print_r() function ASP/VBScript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway