klik

Experience

150

0 Best Reply Awards

  • Member Since 4 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

23rd May, 2018

klik left a reply on Can't Display Preg_match Return Array. • 2 months ago

I know, it's only test code. Thx.

klik left a reply on Can't Display Preg_match Return Array. • 2 months ago

That match[0] exists in every case. Now I did a test using explode method and I have the same situation. Index dosn't exist but var_dump() shows it exists. Is it a bug?

klik left a reply on Can't Display Preg_match Return Array. • 2 months ago

Hi. WTF?

This one works.

return $match[0] ?? '';

But this one doesn't.

return $match[0];

But what is a difference? In both cases match[0] exist, so why in your example I can return value but no when do return $match[0]?

Thank you.

22nd May, 2018

klik started a new conversation Can't Display Preg_match Return Array. • 2 months ago

Hi. I created new helper file and added function that using preg_match to check string.

In HTML: {{commentAnswerTo($comment->content)}}

In helper: function commentAnswerTo(string $text) { preg_match("/[|][a-z0-9_ąśżźćńłóę]+[|]/i",$text,$match); var_dump($match); }

As a result I have: array(1) { [0]=> string(7) "|Usuri|" } And result is absolutely correct.

But when I try get value from array:

echo $match[0];

then I have error: Undefined offset: 0 (View: \resources\views\post\view.blade.php).

Why I can't get this value?

I did a test adding string in function:

function commentAnswerTo(string $text) { $test = '|Usuri| This is a random text in comment'

preg_match("/[|][a-z0-9_ąśżźćńłóę]+[|]/i",$test,$match);
echo $match[0];   

}

And then I can get a value from array. So why I can't when I pass string as a function parameter?

Thank you.

14th May, 2018

klik left a reply on Display Formated Text From TinyMCE And Prevent XSS • 3 months ago

Thank you.

12th May, 2018

klik started a new conversation Display Formated Text From TinyMCE And Prevent XSS • 3 months ago

Hi. In my website I would like to let users add text using TinyMCE editor with some basic html tags (p, br, span, strong etc.). Later of course I would like to display added post with that formatted text.

And now I have a problem. If I use {{ $post->content_text }} then laravel remove all html tags. I can use {!! $post->content_text !!} and display proper formatted text but then I leave the door wide open for XSS attack.

So what is a solution to display formatted text and prevent XSS?

Thank you.

4th May, 2018

klik left a reply on Show Popular [tag] By How Much The Tag Count Per Post • 3 months ago

Hi. Your solution "jovanita" works fine for me. Thank you. I have only one question, how to get name of tags next to tags id.

Regards

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.