Reply to Re: what function will split text

Your name:

Reply:


Posted by Jerry Gitomer on 09/30/06 20:30

ashok wrote:
> Hi,
> I need a function that will divide text from mysql in 2 parts, so that I
> can display first half in one column and second half in second column.
> I can't find what function will do this job.
> Here is part of what I have.
>
> $myrow = mysql_fetch_assoc($rsindexpage);
> //function wordcount
> $wc = str_word_count($myrow);
> $half = ($wc/2);
> //function divide text in two columns
> <tr>
> <td width="150" valign="top">
> <?php
> $str = $myrow;
> $split = NEED_FUNCTION_HERE($str, $half);
> $first = $split[0];
> $second = $split[1];
> echo "$first";
> ?>
> </td>
> <td width="150" valign="top">
> <?php
> echo "$second";
> ?>
> </td>
> </tr>
>
>
Look at the substr function. The syntax is:

substr(<string name>, <start position>, <length>)

so, assuming a string of length 150 that you
want to split into two equal parts:

$first = substr($str, 0, 75);
$second = substr($str, 75, 75);

HTH

Jerry

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация