| | |
What is solution to this query
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
Hi friends
This is Radhika
Here is the Query:
$str=strlen("Welcome to Program of PHP");
this is o/p:25
But my query is
it should read how many words we like
for example:uptill "welcome":
output is :7....... remaining part should be printed like dots etc.
But use single function only.
advance thanks
Radhika
This is Radhika
Here is the Query:
$str=strlen("Welcome to Program of PHP");
this is o/p:25
But my query is
it should read how many words we like
for example:uptill "welcome":
output is :7....... remaining part should be printed like dots etc.
But use single function only.
advance thanks
Radhika
What exactly are you asking for? What is a word "we like"? It will probably be possible to write a function to do what you want but I'm not entirely sure what that is.
All in all, what info do you want to get out of the function and what info do you need to put in?
All in all, what info do you want to get out of the function and what info do you need to put in?
★ "If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
•
•
Join Date: Aug 2007
Posts: 189
Reputation:
Solved Threads: 14
Radhika, the problem can be resolved very easy step by step, would be necessary first to make an explode(), separating words using a space delimiter. The result will be an array with each index followed by a word.
Now, inside the function, the for loop will iterate the passed argument (desired words quantity). On each iteration, concatenate a variable passing each array element using as key the variable used into the for loop. Note: Add a space if it's necessary too between each concatenation. Also, due to the array start with zero value, the first passed argument should be decreased once.
After the loop, you will have a variable only with some words passed, you can finally apply strlen() to count the elements.
Good luck :-)
Now, inside the function, the for loop will iterate the passed argument (desired words quantity). On each iteration, concatenate a variable passing each array element using as key the variable used into the for loop. Note: Add a space if it's necessary too between each concatenation. Also, due to the array start with zero value, the first passed argument should be decreased once.
After the loop, you will have a variable only with some words passed, you can finally apply strlen() to count the elements.
Good luck :-)
![]() |
Similar Threads
- simple query about cout (C)
- Problem with query. (MS SQL)
- Secure MP3 Downloads ?? Help Needed (PHP)
- problem with date query (ASP)
- Need Urgent Solution (Visual Basic 4 / 5 / 6)
- transfer page (ASP.NET)
- Cheapish Graphics Card Query (Monitors, Displays and Video Cards)
- Dynamic Query (JSP)
- How do you integrate a database w/web design? best solution for online catalogue? (Database Design)
- Please check and provide solution for my code (ASP)
Other Threads in the PHP Forum
- Previous Thread: mysql_num_rows
- Next Thread: help in sending php array to mysql table
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess action ajax apache api array auto beginner binary broken cakephp checkbox class cms code cron curl database date dehasher destroy directory display domain download dynamic echo email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image include insert integration ip java javascript joomla limit link load login loop mail masterthesis menu mlm mod_rewrite multiple mysql oop paypal pdf php popup problem query radio random record recursion regex remote script search security server sessions sms soap source space sql syntax system table tutorial update upload url validation validator variable video web xml youtube





