Re:What php function is used for giving .... (1 viewing) (1) Guests
Post Reply << Start < Prev 1 2 Next > End >>
What php function is used for giving ....
by jahflasher 1 Year, 6 Months ago
I have long test out put from queries. how can i get the text to have .... after a specified number of letters?
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:What php function is used for giving ....
by cyberpunk 1 Year, 6 Months ago
Code: :

  <? $output 'aaabbbcccdddeeefffggghhhiiijjj'//this is an example output //we will solve using the str_split function $x //i'm just using a figure you can //set x to be the amount you //want it separated by $blar  str_split($output$x); $loopcontrol count($blar);  //count the array to see how many index's //it has we will use this as  //our loop controller $finaloutput ''//initialize as a global string for($x=0$x<$loopcontrol$x++){   $finaloutput.= $blar[$x] . "...";   $x 2; //increment by 2 so as to move to //the next point where we  //wanna insert the ...  } echo $finaloutput// should be  //aaa...bbb...ccc...ddd... etc ?>



hope this helps tested and worked i made a hange while typing it here but it shouldn't affect it.

Post edited by: cyberpunk, at: 2007/06/21 15:53

Post edited by: cyberpunk, at: 2007/06/21 15:56
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:What php function is used for giving ....
by Infidel 1 Year, 6 Months ago
death to you coders!!!!!
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:What php function is used for giving ....
by jahflasher 1 Year, 6 Months ago
Thanks very much . I love your site. Cool design.
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:What php function is used for giving ....
by cyberpunk 1 Year, 6 Months ago
Welcome @leoten10. Please lemme know if it works for you
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:What php function is used for giving ....
by jahflasher 1 Year, 6 Months ago
this is a little too advanced. i tried an easier method:
$var = "this is the information that i want well then";

echo substr_replace($var, ' ...', 25, -1) ; ?>
only problem is that it does not remove the last character in the var string so i get some thing like :

"the is the information tha ...n"

where p is the last character in the string. So my question is how do i remove the last character or is ther a better way to do it?

Post edited by: jahflasher, at: 2007/06/25 05:38
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:What php function is used for giving ....
by cyberpunk 1 Year, 6 Months ago
in your example above? what was var equal to in the first place. I need to know so i can compare to your output to see what your substr_replace did to it.


and are you saying that you want "..." to be the final characters for the string??

please be clear in what your asking. i thought you wanted to put a certain string "..." after x amount of characters in a string.

From what yoru assking you just waant to put ... after say x amount of characters and not every x characters.

therefore

Code: :

  $var="this is a string of text written by cyberpunk"; // var contains 45 characthers within its string $output substr($var025); // this grabs characters from position 0 // of the string to position 25 $output .= "...";



This should give the effect that it seems your looking for.

Post edited by: cyberpunk, at: 2007/06/25 05:47

Post edited by: cyberpunk, at: 2007/06/25 05:54

Post edited by: cyberpunk, at: 2007/06/25 06:04
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:What php function is used for giving ....
by jahflasher 1 Year, 6 Months ago
thanks. simple concatenation wow.
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:What php function is used for giving ....
by jahflasher 1 Year, 6 Months ago
i am getting unexpected '.'. take a look at my code block to see if i am doing something wrong:
Code: :

  <?php $churchname $_GET['churchname'];  $output substr($churchname025) ; echo $output = ." ..."?>



Post edited by: cyberpunk, at: 2007/06/25 06:05

Post edited by: jahflasher, at: 2007/06/25 06:05
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:What php function is used for giving ....
by cyberpunk 1 Year, 6 Months ago
my bad. another typo by me. :| i corrected my post above. the line

Code: :

 echo $output = . " ..."

you have there should be

Code: :

 echo $output .= " ..."



you could add this condition if you decide to

Code: :

  if(substr($output, -1) == " "){  $output substr_replace($output,'',-1); }




place it below this line

Code: :

 $output substr($var025);



that'll grap the last value of your output test if its a null string and remove it before appending " ...".

so you wont end up with

string ... but
string ... (only 1 space. looks better to me)

place the code block for the space check right below

Post edited by: cyberpunk, at: 2007/06/25 06:16
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Post Reply << Start < Prev 1 2 Next > End >>
 
     
Powered by FireBoardget the latest posts directly to your desktop