PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 11th, 2004, 08:26 PM
TylerNZ TylerNZ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 TylerNZ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
join php string variables ???

Hi, could someone please tell me how I can join two php string variables?! Here's my code:
PHP Code:
for ($i=0$i<$children$i++) 
{
$child_name.$i htmlentities($_POST['child_name$i']);
$child_age.$i htmlentities($_POST['child_age$i']);
$child_mom.$i htmlentities($_POST['child_mom$i']);
$child_require.$i htmlentities($_POST['child_require$i']);


???

THANKS!

Reply With Quote
  #2  
Old April 14th, 2004, 07:26 AM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
hi... if i understand u right, u wanna ei. store a new wariable, that has several of the strings u printet above in it... ?! if that is so, then you can do it like this:

PHP Code:
 $child_name.$i htmlentities($_POST['child_name$i']);
$child_age.$i htmlentities($_POST['child_age$i']);

$new_string $child_age $child_name ;

print 
"$new_string"


this should merge the two strings.

- Pheifel

Reply With Quote
  #3  
Old June 3rd, 2004, 03:01 PM
mrigesh mrigesh is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 mrigesh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up join variables and strings or variables and variables

i.e http://www.msn.net/mrigesh.php?child_name1=Mrigesh the great&

actual code
$i=1;
$child_name.$i =$_GET['child_name'.$i]

echo $child_name.$i;

will print:Mrigesh the great;


If this doesn't help, somethin's wrong with your head not the code.
And by the way the above two posts doesn't work, don't even try those.

Mrigesh Rajbhandari,
Php Administrator
"glory of God is intelligence"

Reply With Quote
  #4  
Old June 3rd, 2004, 03:36 PM
edwinbrains's Avatar
edwinbrains edwinbrains is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: UK
Posts: 160 edwinbrains User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 5 m 50 sec
Reputation Power: 5
mrigesh: there was no need to report Pheifel's post, just because it doesn't work. When you report a post, it says:

Note: This is ONLY to be used to report spam, advertising messages, and problematic (harassment, fighting, or rude) posts.

His post is none of these.

Anyway, your code doesn't work straight away - it is missing a semi-colon from the end of the second line.

Quote:
Originally Posted by mrigesh
If this doesn't help, somethin's wrong with your head not the code.


That was nice and modest of you.

Reply With Quote
  #5  
Old June 3rd, 2004, 04:56 PM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
Lol

I wa reportet... Giggles. Thats funny. Taken into comparison, that i have helped more. And are more actice than you (mrigesh) On the other hand. That post is in the sence precisly why the repport-function is there.

- Pheifel

Reply With Quote
  #6  
Old June 4th, 2004, 12:30 PM
fizker fizker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: denmark
Posts: 42 fizker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 18 m 18 sec
Reputation Power: 5
Send a message via MSN to fizker
actually, i am not entirely sure that you can do this: $child_name.$i. i haven't tried it myself, but it might work. if it doesn't, i would recommend using arrays.

This would do pretty much the same:
PHP Code:
for ($i=0$i<$children$i++) 
{
$child_name[$i] = htmlentities($_POST['child_name$i']);
$child_age[$i] = htmlentities($_POST['child_age$i']);
$child_mom[$i] = htmlentities($_POST['child_mom$i']);
$child_require[$i] = htmlentities($_POST['child_require$i']);

__________________
Benjamin Horsleben
horsleben.com/benjamin
Don't blame malice for what stupidity can explain

Reply With Quote
  #7  
Old June 21st, 2004, 11:47 AM
sintrigue sintrigue is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 12 sintrigue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This works - try it yourself and see:
<?
$text1 = 'Some';
$text2 = ' Text';
$text3 = $text1 . $text2;
echo $text3;
?>

This will print "Some Text" -- but notice the space at the front of $text2.
You could just have easily put a $spacetext in there for a space. <shrugs>
You could also use it to, say, add a tab space in front of your text, and
even use with your "post" tag, such as:

<?
$text1 = '&nbsp;&nbsp;&nbsp;';
$text2 = ($_POST['textboxdata']);
$text3 = $text1 . $text2;
echo $text3;
?>

This would produce something like: (five spaces here)This is the contents of the textbox!

Cheers,

Sintrigue

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > join php string variables ???


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 3 hosted by Hostway