|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #55806 preg_grep( )function is giving result but not valid
Submitted: 2011-09-28 14:04 UTC Modified: 2011-12-03 22:48 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: engrfawadghafoor at gmail dot com Assigned:
Status: No Feedback Package: Output Control
PHP Version: 5.3.8 OS: windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: engrfawadghafoor at gmail dot com
New email:
PHP Version: OS:


 [2011-09-28 14:04 UTC] engrfawadghafoor at gmail dot com
From manual page:

Test script:
$var = ucfirst ($_REQUEST['queryString']);
for($i=0; $i<sizeof($friends_inner); $i++)
$selected_friend_id=$selected_friend['id']; //array of ids
$selected_friend_name=$selected_friend['name']; // array of names
$result=preg_grep('/^'.$var.'.*/', $name);
(to be note)
this will show different result
echo "total elements in matched array name = ".count($result)."<br>";

$maxindex = array_pop(array_keys($result));
for($i=0;$i<=$maxindex;$i++){                 //returns array that start with zero
function sort_arrays($final_result,$friends_inner) {
	$ids_of_result = array();
	foreach($final_result as $fnl_rslt){
		foreach($friends_inner as $frnd_in){
			if($fnl_rslt == $frnd_in['name']){
				//echo 'Name : '.$frnd_in['name'].'<br>';
				//echo 'Id : '.$frnd_in['id'].'<br>';
	return $ids_of_result;
$ids_of_result = sort_arrays($final_result,$friends_inner);	
(to be note)
this will  show different result
echo "total elements in match array ids =  ".count($ids_of_result)."<br>";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-28 14:29 UTC]
Can you provide a cleaner example, showing the data you are using and the expected 
and actual results please? Your test script is specific to your requirements and 
your data.
 [2011-12-03 22:48 UTC]
-Status: Open +Status: No Feedback
 [2011-12-03 22:48 UTC]
It's been two months now. I don't think we're going to get the feedback we need. 
If feedback is provided, reopen the bug.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 17 21:01:28 2024 UTC