| | |
Find random string between main string?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Yes, you described that, which is why I posted a link describing how to do it.
Last edited by ShawnCplus; Sep 11th, 2009 at 6:01 pm.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
•
•
•
•
hi,
my string is
$string="Sign up for Facebook to connect with Jean Profession";
i want to find word randomly from string
like :- connect or Profession whose length >4 and this word not is a facebook.
String functions: http://us2.php.net/manual/en/book.strings.php
Probably the simplest way to go about it is to explode() the string into an array of words.
eg:
PHP Syntax (Toggle Plain Text)
$array = explode(" ", $string);
Then loop each array values (each word) counting characters with strlen().
For an intro to regular expressions see: http://www.regular-expressions.info/
It also goes into it in depth after a while. Regex is a really useful tool to learn, and is implemented similarly across programming languages. The flavor PHP currently uses is PCRE. http://www.pcre.org/
The PHP docs: http://www.php.net/pcre
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Try this:
php Syntax (Toggle Plain Text)
<? $string='Sign up for Facebook to connect with Jean Profession'; $word=explode(' ',$string); $b=(count($word)-1); $b=mt_rand (0,$b); echo $word[$b]; ?>
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - MacGyver Fan
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - MacGyver Fan
![]() |
Similar Threads
- Return todays date as a String (C++)
- Converting std::string to System::String^ NEED HELP (C++)
- Problem of abruptly termination... (C++)
- concatination of integer string to char string (C)
- Comparing two letters in one string with another char string? (C)
- string to long and string to double in c (C)
- string: get token from string and compare token from text file (C++)
Other Threads in the PHP Forum
- Previous Thread: Trouble with is_null()
- Next Thread: Adding up numbers in array
| Thread Tools | Search this Thread |
.htaccess action ajax apache api array auto beginner binary bounce broken cakephp checkbox class cms code cron curl database date display dynamic echo email error errorlog file files folder form format forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla limit link login loop mail malfunctioning masterthesis menu mlm mod_rewrite multiple mysql nodes oop paypal pdf php popup problem query radio ram random recursion reference regex remote return script search server sessions sms soap source space sql syntax system table tutorial unset update upload url validation validator variable video web websitecontactform xml youtube






