Jump to content

Matching spaces in names


9three

Recommended Posts

If the name is a string by itself, I agree with rajivgon's solution (using explode). As usual, there are numerous ways to skin a cat.

 

Another alternative (of perhaps plenty of possibilities) could be to make use of say sscanf:

$str = 'Jason Fernandez';
sscanf($str, "%s %s", $firstName, $lastName);
echo "$firstName<br />\n$lastName";

 

In either case, for problem solving things like this, regex would not be what I'd use.

I really like the sscanf function. It's easier to assign variables to it instead of using explode and doing something like

 

$firstName = $arrName[0];

$lastName = $arrName[1];

 

What's wrong with:

list($firstName, $lastName) = explode(…);

What's wrong with:

list($firstName, $lastName) = explode(…);

 

I suspect the list functionality is something the OP isn't aware of? Yet another example of how things can be done. ;)

 

[ot]Sometimes I feel like programming is comparable to a buffet. Plenty of options, walk away feeling satisfied.[/ot]

[ot]Is there any way not to mung the post's HTML when someone pastes a print_r output without code tags? It seems to happen fairly often resulting in problem <ul>s. "Remind the OP to use code tags" is of course an option too. [/ot]

 

I'm not sure if this is related to disabling WYSIWYG or not.. but perhaps trying that.

From top menu, Click profile, then in drop-down sub menu, Modify Profile >  Look and Layout - within Look and Layout, ensure "Show WYSIWYG on post page by default is unchecked.

 

If this doesn't do it, then I'm unsure what the solution is to be honest.

[ot]It's not when editing, the problem is how post text is parsed when viewing posts/topics. SMF is parsing print_r text (Array( [0] => ... [1] => ... )) like in the first post of this thread. I know everyone should be using code tags, and that we all know what the poster means when things get "broken" like that, but surely** it can't be difficult to persuade SMF to only parse tags like that when wrapped with the appropriate wrapping tags ([ul] or whatever) or ignore them if preceded by the particular sequence of characters in a print_r value.  I don't know, maybe that's too much hard work and we just just yell at people to use code tags and/or ignore the problem. :shy:

 

** Famous last words.[/ot]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.