Jump to content
php.lv forumi

Recommended Posts

Posted

Tātad ir dots $teksts kas satur vairākas rindiņas

$teksts = 'Rinda 1
Rinda 2
Vel kautkas
Un ta talak';

Vajadzētu apstrādāt katru rindiņu piemēram kā ar foreach ($lines as $line_num => $line) bet šis sanāk tikai nolasot failu.

 

Kādi ieteikumi?

Posted

Tātad ir dots $teksts kas satur vairākas rindiņas

$teksts = 'Rinda 1
Rinda 2
Vel kautkas
Un ta talak';

Vajadzētu apstrādāt katru rindiņu piemēram kā ar foreach ($lines as $line_num => $line) bet šis sanāk tikai nolasot failu.

 

Kādi ieteikumi?

 

$arr = explode("\r\n",$teksts); //\r\n vai \n
foreach($arr as $line => $item){
echo ($line + 1) . ". rindiņā ir teksts: $item<br />";
}

Posted

$arr = explode("\r\n",$teksts); //\r\n vai \n
foreach($arr as $line => $item){
echo ($line + 1) . ". rindiņā ir teksts: $item<br />";
}

paldies!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...