how do you prepend a value to a string.
For example
$a='great';
prepend 'pop ' to $a;
$a == 'pop great';
sort of like the reverse of .=
how do you prepend a value to a string.
For example
$a='great';
prepend 'pop ' to $a;
$a == 'pop great';
sort of like the reverse of .=
So I don't get what you mean.
When you use .= have the text go in the beginning not front?
Jeremy | jfein.net
yes.
What I want to do is the opposite. I want to know if there is some sort of function or way that I can prepend the string so that you can add 'so ' to $a to make $a become 'so what if?'.Code:$a='what'; $a.=' if?'; //$a becomes 'what if?';
because $a already has a pregenerated value. Nice thought though. I just found this simple answer though
$a='if?';
$b='what ';
$a="$b$a";
//$a becomes "what if?"
Last edited by james438; 02-25-2008 at 03:37 AM. Reason: typo
No. You appended the string. I prepended the string. Since it is short here is the code that I am using it in:
to do what you suggested would erase the passed value, which is why I needed to prepend the string.Code:<?php $a=0;$b='0000000'; foreach ($_POST as $field[] => $value[]) { if (strpos($field[$a],'check')===0) else $value[$a]="$b$value[$a]"; echo "$field[$a] = $value[$a]<br>";$a++; } echo "pp $_POST[loot_Lasl] pp"; ?>
P.S. the script is only in its infancy, so no need to critique it. I am merely designing it right now.
Code:$a = ' if?'; $a = 'What' . $a;$a .= $bis just a short form of$a = $a . $b.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
that works too![]()
Bookmarks