PHP Tutorials: Name Splitter (Part 1)
Splits a full name into two seperate variables. Useful for signup forms where you just want to ask the user their full name, and not have two seperate boxes for first and last names.
Duration : 0:9:20
Splits a full name into two seperate variables. Useful for signup forms where you just want to ask the user their full name, and not have two seperate boxes for first and last names.
Duration : 0:9:20
???
???
Thanks, great …
Thanks, great tutorials, just suscribed, keep them coming.
yeap, you right, …
yeap, you right, this is quite a raw mistake, if there will be no spaces – there will be exception, or something other in php, I have miserable experience in this language
Nice tutorial, …
Nice tutorial, except two points …
1. for ($x=0; $x<$len; $x++) … (you should use < and not <=)
2. if you use mb_substr then you should also use mb_strlen
thank you … very …
thank you … very helpful tutorial ..keep up the good works
You guys should be …
You guys should be grateful God gave Alex a heart so he could share an information that you have to pay college money to learn.
Dont try correcting him, Hes showing another way you TARDFAGS
Your lucky he still posts videos and gives away information for free
Hi Alex, I am just …
Hi Alex, I am just showing my support and letting you know I really enjoy this tutes. I learn from you and killerphpdotcom.
My objective is to become a MySQL DBA so I thought a good place to start would be to focus on PHP. I already have my AAS in Information Systems Tech. I post something about get having a 1,000 limit storage capacity instead of a 100 character. Im really not sure can you clarify that for me thanks again.
I’d recommend you …
I’d recommend you gain some basic knowedge of PHP before you a) start to learn some more advanced algorithms like this one and b) give bad feedback like this when I’ve put so much effort into FREE CONTENT.
how is he going to …
how is he going to fast? unless you’ve gone straight to this tutorial and not watched the basics then i’m not surprised
Oke, forgot to say …
Oke, forgot to say that people will learn the purpose of a function. So in that way good tutorial.
You loop through …
You loop through all letters to discover a space. Not really efficient. On the other hand, like others said, explode is much less code.
If you do not want to create an array, you can also use ´strpos’ to get the position of the last space (or only space) in the string. If there are no spaces, it will return false. If it has, you then just simply can use mb_substr to split.
But 3 fields cannot be avoided. Firstname, middlename & lastname is I think not to much to ask.
Why don’t you try …
Why don’t you try to start from the FIRST Class… ( Basics )
I just realized …
I just realized below that you noted this was just for logic lesson. Guess I didn’t read the comments first. I think logic could still be explained a bit more easier.
It would seem to me …
It would seem to me you could just take the $string = explode(” “, $name) to get an array, count the array out, and then you could ign each value. so if a person has ” James Tiberius Kirk ” as their name, you can effectively grab their middle name too. Make sure to trim the initial text of course. This is just my thoughts.
How do you figure …
How do you figure that? I’m pretty far in PHP and I know he is explaing everything about PHP the HTML he doesn’t need to explain you should know HTML before learning PHP.
You go to fast and …
You go to fast and don’t explain.
Horrible.
I’ve explained this …
I’ve explained this before, I’m basically teaching this for the purpose of getting your head around logic. I know the explode would be quicker, but you’d be learning a function and not know how it works!
DUDE??
Why So Long. …
DUDE??
Why So Long..
Just Use Explode And ForEach…
Lol
Hmm, why bother …
Hmm, why bother using (mb_)substr for echoing the name. Just use: $fullname[$x].
Glad to see somebody else is doing PHP tutorials though
$lastname value is …
$lastname value is ” ” and not “Garret”
instead
$firstname is “AlexGarret”
I don’t understand the logic..
program is wrong in the logic.
hii your r sow good …
hii your r sow good in php
True, even though I …
True, even though I know all of this, it’s good practice to learn the language in every way.
The point of this …
The point of this was to teach people the logic of string operation. Yes, someone can use split, but then then may not be very good at programing logic.
if you use split(); …
if you use split(); this will be fine ..