Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9167673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:26:53+00:00 2026-06-17T15:26:53+00:00

<?php function get_video() { $stripper = Content…[video=1], content…content…[video=2], content…content…content…[video=1], no more…; preg_match_all(/\[video=(.+?)\]/smi, $stripper, $search);

  • 0
<?php

function get_video() {

$stripper = "Content..., content...content...,
             content...content...content..., no more...";

preg_match_all("/\/smi", $stripper, $search);  

$unique = array_unique($search[0]);

$total = count($unique);     
for($i=0; $i < $total; $i++) 
{    
  $vid = $search[1][$i]; 
  if ($vid > 0) 
  {      
    $random_numbers = rand(1, 1000);
    $video_id = $vid."_".$random_numbers;
    $stripper = str_replace($search[0][$i], $video_id, $stripper); 
  } 
} 
return $stripper;
}  

echo get_video();   
?>

I want to remove duplicate in $stripper, this is the result i need:

Content...1_195, content...content...2_963, 
content...content...content..., no more...

I am using array_unique() function to remove the duplicate array. From my code above, if i print_r($unique), the duplicate array has been removed:

Array ( [0] =>  [1] =>  )

But if i echo get_video(), the duplicate still exist:

Content...1_195, content...content...2_963, 
content...content...content...1_195(), no more...

I can’t figure out why!!! 🙁

Demo: http://eval.in/7178

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:26:55+00:00Added an answer on June 17, 2026 at 3:26 pm

    To remove duplicates execute a preg_replace_callback and replace the duplicate one by “”. Use the following code just before your preg_match_all call,

    $hash = array();
    $stripper = preg_replace_callback("/\/smi",function($m){
        global $hash;
        if(isset($hash[$m[0]]))
            return "";
        else{
            $hash[$m[0]]=1;
            return $m[0];
        }
    }, $stripper);   
    

    See http://eval.in/7185

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written a PHP function to get plus ones count for a URL function
The following code works for Vimeo API: function getTitle($id){ $title = unserialize(file_get_contents(http://vimeo.com/api/v2/video/$id.php)); $theTitle=$title[0]['title']; echo
I have a PHP/jQuery scraper function that essentially looks for web page content. One
I've a php function to get some data from mysql database: function get_persons() {
Can anyone describe the following php function: function get_setting_value($settings_array, $setting_name, $default_value = ) {
I'm using PHP's function file_get_contents() to fetch contents of a URL and then I
Can anyone explain the following PHP Code ? function get_param($param_name, $param_type = 0) {
my sample code is here include 'simple_html_dom.php'; function get_all_links($url){ global $host; $html = new
$(function() { setInterval(function() { $.get(refresh.php, function(result) { $('#response').empty() .hide() .html(result) $(#response).append(result) .fadeIn(slow); }); },
I am using this function to get the featured images: <a href=# rel=prettyPhoto> <?php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.