Posts | ||
---|---|---|
[PHP]Some help..not hard | Locked | |
Thread Options | ||
Apr 14 2003 Anchor | ||
I hope this belongs in Tech Support. Anyhow, I'm really new at PHP, and I've decided to ditch trying to learn SQL.. all those programs aren't working for me. I like a programming language, not a ton of executables and stuff. Okay, now for the thing. I want to change all spaces in a string to plus signs '+'. Don't tell me oh, the browser changes them to %20 anyway, I just want to know how to replace stuff in a string. If you have a string called $pie, can you access individual characters like in C? For instance: $pie = "I LIEK PIE"; also, Intense said there was no data type casting in PHP, but some tutorial had this! That looks like casting to me! --
|
||
|
Apr 14 2003 Anchor | |
pretty sure u can do it... strreplace, or somethin like that... its one of the str commands, look at php.net s list of commands... -- ___________________________
|
||
Apr 14 2003 Anchor | ||
Okay, thanks, str_replace replaces all occurrences of a string in another string. I guess I could use one-character strings, yes Thank you pf, you are definitely not the person I was expecting an answer from! But there are still parts 2 and 3 of my first post in effect --
|
||
|
Apr 14 2003 Anchor | |
dunno, thats as far as i got in php it confused the hell out of me, considering i have no background in any formal coding outside of html i remember something that did this though.... substr_replace perhaps? -- ___________________________
|
||
Apr 14 2003 Anchor | ||
Ha, html isn't format coding. Maybe xhtml is though No, str_replace does it fine. By the way, the Fniggium site has been completely PHPized! But there are still parts 2 and 3 of my first post in effect --
|
||
|
Apr 14 2003 Anchor | |
A hundred years ago, a big monster came and ate people and a hero emerged and chosen one and kill monster and save earth and now more monster and now your turn and you are now chosen one and you have to be hero and kill ten thousand monsters and become powerfullest person in world. indeed... btw, what were the other things u wanted to know? -- ___________________________
|
||
Apr 14 2003 Anchor | ||
--
|
||
|
Apr 14 2003 Anchor | |
i believe you can... what are u trying to do with it? there is a command that is used for replacing letters with the foreign characters that sounds like what u want -- ___________________________
|
||
Apr 15 2003 Anchor | ||
Yeah, strtr() I think. --
|
||
|
Apr 15 2003 Anchor | |
i believe that individual characters are accesible, but it depends on what u want to do with them... there might be certain things that u cant do... i sorta have a vague idea about what im talking about, but i dont have anywhere to play around with it, so i dont know how to actually implement these things... i have a questiong also about php, will post in a different thread -- ___________________________
|
||
Apr 15 2003 Anchor | ||
or
-- Why wont it save me? |
||
|
Apr 15 2003 Anchor | |
Apr 15 2003 Anchor | ||
Your first code sample makes little sense to me, azz0r, but thank you for the second one! I'll look eregi_replace on php.net (a handy site indeed). Now, my site has interesting features. The screenshots page lists all files in the images/screenshots/ directory and displays their thumbnails by adding thumbs/ at the end of the directory name. And then, the front page displays four random images from that folder in the center column! Neato, except I don't have any screenshots right now. If you want to check out the code, see the the following code. And then check out the following text files for the code I am so proud of because I'm completely new to PHP! And I only used tutorials to figure out what functions I need to do stuff like get random numbers and read from a directory. And figure out the basic language structure for stuff like variables and arrays. Fniggium.actionrealm.com I suppose I could rename these files to PHP or something so you wouldn't be able to read the source or something, but there's nothing in there that I want hidden. Feel free to look around and critique/suggest/advise/flame/worship me for it! - Edited By SeienAbunae On Tue 15th, Apr 2003 @ 6:52:31pm - Edited By SeienAbunae On Tue 15th, Apr 2003 @ 6:53:33pm --
|
||
|
Apr 15 2003 Anchor | |
since i really have no idea what that means, erm, its good -- ___________________________
|
||
|
Apr 16 2003 Anchor | |
|
Apr 16 2003 Anchor | |
you can easily get any character out of a string i.e. $string = 'hello'; then echo $string{3}; would output 'l' as for your other question, in PHP you do not have to data cast any variables, and you can change between them as you please, however occasionally it is needed as you cannot order a string of numbers for example -- Scott Reismanis |
||
Apr 16 2003 Anchor | ||
$ThemeName = (strtoupper(substr($Theme,0,1)).substr($Theme,1)); Will capitalise $Theme Wuggawoo.co.uk -- Why wont it save me? |
||
Apr 18 2003 Anchor | ||
A PHP equivalent of itoa() maybe? Thanks for the help Intense! So you have to use curly braces {} instead of square brackets []? I guess strings aren't really treated as arrays then... --
|
Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.